【发布时间】:2018-05-03 20:03:45
【问题描述】:
所以我想知道为什么这个 Blob 对象的 size 为 5:
var x = new Uint8Array(2);
x[0] = 255;
x[1] = 10;
console.log("Typed array length is " + x.length + ".")
console.log("Typed array byte length is " + x.byteLength + ".")
console.log("Blob size is " + new Blob(x).size + ' "bytes".')
对我来说这毫无意义,因为Uint8Array 元素可以存储在一个字节内。 (Uint8Array items 可以处理从 0 到 255 的值。)
此外,更改 x[0] 或 x[1] 似乎会更改 new Blob(x).size。但是,x.byteLength 给了我预期的结果。
即使我到处搜索,我也找不到任何解释。
【问题讨论】:
标签: javascript blob typed-arrays uint8array