DataView.prototype.buffer

DataView 实例的 buffer 访问器属性返回该视图在构造时引用的 ArrayBufferSharedArrayBuffer

¥The buffer accessor property of DataView instances returns the ArrayBuffer or SharedArrayBuffer referenced by this view at construction time.

Try it

描述

¥Description

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

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

示例

¥Examples

使用缓冲区属性

¥Using the buffer property

js
const buffer = new ArrayBuffer(8);
const dataview = new DataView(buffer);
dataview.buffer; // ArrayBuffer { byteLength: 8 }

规范

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

¥Specifications

浏览器兼容性

BCD tables only load in the browser

¥Browser compatibility

也可以看看