TypedArray.prototype.byteOffset

byteOffset 访问器属性表示类型化数组距离其ArrayBuffer起始位置的偏移(字节数)。

语法

typedarray.byteOffset

描述

byteOffset 是一个访问器属性,它的 set 访问器函数是undefined,意思是你只能够读取这个属性。它的值在TypedArray构造时建立,不能被修改。TypedArray 是这里的 TypedArray 对象之一。

示例

使用byteOffset 属性

js

var buffer = new ArrayBuffer(8);

var uint8 = new Uint8Array(buffer);
uint8.byteOffset; // 0 (没有指定 oddfet)

var uint8 = new Uint8Array(buffer, 3);
uint8.byteOffset; // 3 (在构造 Uint8Array 时指定)

规范

Specification
ECMAScript Language Specification
# sec-get-%typedarray%.prototype.byteoffset

浏览器兼容性

BCD tables only load in the browser

另见