node js - 在 ArrayBuffer 中存储大量数字
node js - storing large numbers in ArrayBuffer
考虑这段代码:
var b = new ArrayBuffer(2);
b[0] = 1;
b[1] = 23234322442;
单元格 1 中的数字显然大于 1 个字节,但 ArrayBuffer 存储它没有问题,当我打印 b
到控制台时,我可以看到数字在那里。怎么解释?
谢谢。
The ArrayBuffer object is used to represent a generic, fixed-length raw binary data buffer. You cannot directly manipulate the contents of an ArrayBuffer; instead, you create one of the typed array objects or a DataView object which represents the buffer in a specific format, and use that to read and write the contents of the buffer. more
所以,我认为,当您调用 b[1]
时,您不会设置缓冲区的第二个元素。您简单地设置对象的 b.1
属性,它可以是任何东西(数字、字符串、对象、数组)。
考虑这段代码:
var b = new ArrayBuffer(2);
b[0] = 1;
b[1] = 23234322442;
单元格 1 中的数字显然大于 1 个字节,但 ArrayBuffer 存储它没有问题,当我打印 b
到控制台时,我可以看到数字在那里。怎么解释?
谢谢。
The ArrayBuffer object is used to represent a generic, fixed-length raw binary data buffer. You cannot directly manipulate the contents of an ArrayBuffer; instead, you create one of the typed array objects or a DataView object which represents the buffer in a specific format, and use that to read and write the contents of the buffer. more
所以,我认为,当您调用 b[1]
时,您不会设置缓冲区的第二个元素。您简单地设置对象的 b.1
属性,它可以是任何东西(数字、字符串、对象、数组)。