What are Typed Arrays in JavaScript?
A
Arrays that only accept strings B
Arrays that store elements of a specific type C
Regular JavaScript arrays D
Immutable arrays
Analysis & Theory
Typed Arrays allow storing binary data in memory with fixed-size elements of specific types.
Which of the following is a valid Typed Array constructor?
A
Array() B
Float64Array() C
StringArray() D
TypedArray()
Analysis & Theory
`Float64Array` is one of the standard typed array types.
What is the result of `new Uint8Array(4)`?
A
An array with 4 elements, each initialized to 0 B
An array with 8 elements C
A regular array of undefined values D
A buffer object
Analysis & Theory
`Uint8Array(4)` creates a typed array of 4 unsigned 8-bit integers initialized to 0.
Which type would you use for 32-bit signed integers?
A
Uint32Array B
Int32Array C
Int8Array D
Float32Array
Analysis & Theory
`Int32Array` is for 32-bit signed integers.
How can you access an element in a typed array?
A
array.get(index) B
array[index] C
array(index) D
array.value(index)
Analysis & Theory
Like regular arrays, you access elements using bracket notation: `array[index]`.
Which of the following is true about Typed Arrays?
A
They can contain mixed types B
They are fixed in length C
They are slower than regular arrays D
They are part of ES3
Analysis & Theory
Typed arrays have a fixed length and store only one data type.
What does this return?
```js
new Uint8Array([255, 256, -1])[1]
```
A
256 B
0 C
255 D
1
Analysis & Theory
`256` overflows and wraps around to 0 because `Uint8Array` only holds values 0–255.
Which method returns the underlying buffer of a typed array?
A
getBuffer() B
buffer() C
array.buffer D
array.get()
Analysis & Theory
`typedArray.buffer` gives access to the raw memory `ArrayBuffer` behind the array.
What will `new Int16Array(2).length` return?
A
2 B
4 C
0 D
16
Analysis & Theory
The `.length` property returns the number of elements, not the total byte size.
Typed Arrays are most commonly used for:
A
Working with JSON B
Handling dates C
Binary data and performance-sensitive tasks D
String manipulation
Analysis & Theory
Typed Arrays are ideal for binary data processing (e.g., WebGL, audio, files).