Get to know MDN better
此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。
Int8Array 类型数组表示二进制补码 8 位有符号整数的数组。内容初始化为 0。一旦建立,你可以使用对象的方法引用数组中的元素,或使用标准数组索引语法 ( 即,使用括号注释)。
有关构造函数语法和参数的更多信息,请访问 TypedArray.
返回数组中每个元素的大小。在 Int8Array 中这个值为 1。
Int8Array.length此属性为固定值属性,值为 3。查看 Int8Array.prototype.length 获得获取数组内元素个数方法。
Int8Array.prototypeTypedArray 对象的构造原型。
从类数组对象或迭代器生成 int8Array 数组对象。参照 Array.from()
Int8Array.of()以多个参数构造 Int8Array 对象,参照 Array.of()
还从其父接口 TypedArray 继承实例属性。
Int8Array.prototype.constructor这个方法会返回对象的构造原型。默认为Int8Array 构造函数。
Int8Array.prototype.buffer 只读Returns the ArrayBuffer referenced by the Int8Array Fixed at construction time and thus read only.
Int8Array.prototype.byteLength 只读Returns the length (in bytes) of the Int8Array from the start of its ArrayBuffer. Fixed at construction time and thus read only.
Int8Array.prototype.byteOffset 只读Returns the offset (in bytes) of the Int8Array from the start of its ArrayBuffer. Fixed at construction time and thus read only.
Int8Array.prototype.length 只读Returns the number of elements hold in the Int8Array. Fixed at construction time and thus read only.
从其父接口 TypedArray 继承实例方法。
| ECMAScript® 2027 Language Specification # sec-typedarray-objects |
启用 JavaScript 以查看此浏览器兼容性表。
自 ECMAScript 2015 (ES6) 施行,Int8Array 需要使用 new 构造。从当前版本开始,不加 new 而便调用 Int8Array 构造器方法,将报出 TypeError 错误。