Skip to content

Commit

Permalink
[zh-cn]: add the translation of ArrayBuffer.detached (#17058)
Browse files Browse the repository at this point in the history
Co-authored-by: A1lo <[email protected]>
  • Loading branch information
JasonLamv-t and yin1999 authored Nov 22, 2023
1 parent dca1982 commit addf841
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
title: ArrayBuffer.prototype.detached
slug: Web/JavaScript/Reference/Global_Objects/ArrayBuffer/detached
---

{{JSRef}} {{SeeCompatTable}}

{{jsxref("ArrayBuffer")}} 实例的 **`detached`** 访问器属性返回一个布尔值,指示该缓冲区是否已经分离(传输)。

## 描述

`detached` 属性是一个访问器属性,其 set 访问器函数是 `undefined`,这意味着你只能读取此属性。该属性的值在创建 `ArrayBuffer` 时设置为 `false`。如果 `ArrayBuffer`[被传输](/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer#传输_arraybuffer),则该值将变为 `true`,这将使该实例从其底层内存中分离。一旦缓冲区被分离,它就不再可用。

## 示例

### 使用 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
```

## 规范

{{Specifications}}

## 浏览器兼容性

{{Compat}}

## 参见

- {{jsxref("ArrayBuffer")}}
- {{jsxref("ArrayBuffer.prototype.transfer()")}}
- {{jsxref("ArrayBuffer.prototype.transferToFixedLength()")}}

0 comments on commit addf841

Please sign in to comment.