ArrayBuffer.prototype.detached

ArrayBuffer 实例的 detached 访问器属性返回一个布尔值,指示此缓冲区是否已分离(传输)。

¥The detached accessor property of ArrayBuffer instances returns a boolean indicating whether or not this buffer has been detached (transferred).

描述

¥Description

detached 属性是一个访问器属性,其设置的访问器函数为 undefined,这意味着你只能读取该属性。第一次创建 ArrayBuffer 时,值为 false。如果 ArrayBuffertransferred,则该值将变为 true,这会将实例与其底层内存分离。一旦缓冲区分离,它就不再可用。

¥The detached property is an accessor property whose set accessor function is undefined, meaning that you can only read this property. The value is false when the ArrayBuffer is first created. The value becomes true if the ArrayBuffer is transferred, which detaches the instance from its underlying memory. Once a buffer becomes detached, it is no longer usable.

示例

¥Examples

使用分离式

¥Using detached

js
const buffer = new ArrayBuffer(8);
console.log(buffer.detached); // false
const newBuffer = buffer.transfer();
console.log(buffer.detached); // true
console.log(newBuffer.detached); // false

规范

Specification
ArrayBuffer transfer
# sec-get-arraybuffer.prototype.detached

¥Specifications

浏览器兼容性

BCD tables only load in the browser

¥Browser compatibility

也可以看看