DataView.prototype.byteOffset

DataView 实例的 byteOffset 访问器属性返回此视图相对于其 ArrayBufferSharedArrayBuffer 开头的偏移量(以字节为单位)。

¥The byteOffset accessor property of DataView instances returns the offset (in bytes) of this view from the start of its ArrayBuffer or SharedArrayBuffer.

Try it

描述

¥Description

byteOffset 属性是一个访问器属性,其设置的访问器函数为 undefined,这意味着你只能读取该属性。该值是在构造 DataView 时确定的,并且无法更改。

¥The byteOffset property is an accessor property whose set accessor function is undefined, meaning that you can only read this property. The value is established when an DataView is constructed and cannot be changed.

示例

¥Examples

使用 byteOffset 属性

¥Using the byteOffset property

js
const buffer = new ArrayBuffer(8);
const dataview = new DataView(buffer);
dataview.byteOffset; // 0 (no offset specified)

const dataview2 = new DataView(buffer, 3);
dataview2.byteOffset; // 3 (as specified when constructing the DataView)

规范

Specification
ECMAScript Language Specification
# sec-get-dataview.prototype.byteoffset

¥Specifications

浏览器兼容性

BCD tables only load in the browser

¥Browser compatibility

也可以看看