February 2018
Intermediate to advanced
298 pages
8h 22m
English
We saw how to read and write numbers in array buffers. But the method was very cumbersome because we had to call a function every time. Typed arrays let us read and write to an ArrayBuffer object just like we do for normal arrays.
A typed array acts as a wrapper for an ArrayBuffer object and treats data from an ArrayBuffer object as a sequence of n-bit numbers. The n value depends on how we created the typed array.
Next is a code example that demonstrates how to create an ArrayBuffer object and read/write to it using a typed array:
const buffer = new ArrayBuffer(80);const typed_array = new Float64Array(buffer);typed_array[4] = 11;console.log(typed_array.length);console.log(typed_array[4]);
The output is:
1011
Here we created ...
Read now
Unlock full access