Saturday, June 12, 2021

efficient JavaScript: ArrayBuffer & typed arrays

JavaScript typed arrays - JavaScript | MDN

JavaScript typed arrays are array-like objects that provide a mechanism for reading and writing raw binary data in memory buffers.

To achieve maximum flexibility and efficiency, JavaScript typed arrays split the implementation into buffers and views. A buffer (implemented by the ArrayBuffer object) is an object representing a chunk of data; it has no format to speak of and offers no mechanism for accessing its contents. In order to access the memory contained in a buffer, you need to use a view. A view provides a context — that is, a data type, starting offset, and the number of elements — that turns the data into a typed array.

Typed arrays in an ArrayBuffer

ArrayBuffer - JavaScript | MDN

Uint8Array - JavaScript | MDN

ArrayBuffer, binary arrays


How to convert ArrayBuffer to and from String  |  Web @developers.google


Typed Arrays: handling binary data (advanced) • JavaScript for impatient programmers (ES2021 edition)