node.js - Node js - 在 ArrayBuffer 中存储大量数字

标签 node.js 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 属性,它可以是任何内容(数字、字符串、对象、数组)。

关于node.js - Node js - 在 ArrayBuffer 中存储大量数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38655707/

相关文章:

javascript - Three.js:如果我有所有必要的缓冲区,如何创建新的 'morphing' 几何体?

javascript - 执行外部 Javascript NodeJS

javascript - 在nodejs中一段时间​​后挂断http连接

multithreading - 在顺序执行的线程中使用ArrayBuffer?

xmlhttprequest - ArrayBuffer 与 Blob 和 XHR2

javascript - 如何将数组缓冲区数据与字符串/json 一起发送到 NodeJS 服务器

node.js - 如何在 sequelize 中使用非列变量

javascript - 如何从一个中间件获取另一个中间件中的数据?

javascript - 如何强制 node.js 进行更深层次的递归?

javascript - IE 的 ArrayBuffer.prototype.slice 垫片?