TypedArray & buffer
TypedArray & buffer
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
// create a TypedArray with a size in bytes
const typedArray1 = new Int8Array(8);
typedArray1[0] = 32;
const typedArray2 = new Int8Array(typedArray1);
typedArray2[1] = 42;
console.log(typedArray1);
// Int8Array [32, 0, 0, 0, 0, 0, 0, 0]
console.log(typedArray2);
// Int8Array [32, 42, 0, 0, 0, 0, 0, 0]
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/buffer
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer
buffer = new ArrayBuffer(8);
// ArrayBuffer(8) {}
view = new Int32Array(buffer);
// Int32Array(2) [0, 0]
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/12749280.html
未经授权禁止转载,违者必究!