Skip to content

Commit

Permalink
[zh-cn]: add the translation of ArrayBuffer.resizable (#17084)
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonLamv-t authored Nov 24, 2023
1 parent e577923 commit 597a975
Showing 1 changed file with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
title: ArrayBuffer.prototype.resizable
slug: Web/JavaScript/Reference/Global_Objects/ArrayBuffer/resizable
---

{{JSRef}}

{{jsxref("ArrayBuffer")}} 实例的 **`resizable`** 访问器属性返回此数组缓冲区是否可以调整大小。

{{EmbedInteractiveExample("pages/js/arraybuffer-resizable.html")}}

## 描述

`resizable` 是一个访问器属性,其 set 访问器函数是 `undefined`,这意味着你只能读取该属性。该属性的值在数组创建时就确定了。如果在构造函数中设置了 `maxByteLength` 选项,`resizable` 将返回 `true`;否则,它将返回 `false`

## 示例

### 使用 resizable

在这个示例中,我们创建了一个 8 字节缓冲区,该缓冲区可调整到的最大长度为 16 字节,然后检查它的 `resizable` 属性,如果 `resizable` 返回 `true` 则调整它的大小:

```js
const buffer = new ArrayBuffer(8, { maxByteLength: 16 });

if (buffer.resizable) {
console.log("缓冲区可以调整大小!");
buffer.resize(12);
}
```

## 规范

{{Specifications}}

## 浏览器兼容性

{{Compat}}

## 参见

- {{jsxref("ArrayBuffer")}}
- {{jsxref("ArrayBuffer.prototype.maxByteLength")}}
- {{jsxref("ArrayBuffer.prototype.resize()")}}

0 comments on commit 597a975

Please sign in to comment.