Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[zh-cn]: update the translation of ArrayBuffer.isView() #17073

Merged
merged 2 commits into from
Nov 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ slug: Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView

{{JSRef}}

**`ArrayBuffer.isView()`** 方法用来判断传入的参数值是否是一种 `ArrayBuffer` 视图(view),比如类型化数组对象([typed array objects](/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/TypedArray))或者数据视图( {{jsxref("DataView")}}
**`ArrayBuffer.isView()`** 静态方法判断传入值是否是 `ArrayBuffer` 视图之一,例如[类型化数组对象](/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) {{jsxref("DataView")}}。

{{EmbedInteractiveExample("pages/js/arraybuffer-isview.html")}}
{{EmbedInteractiveExample("pages/js/arraybuffer-isview.html", "shorter")}}

## 语法

Expand All @@ -18,17 +18,16 @@ ArrayBuffer.isView(value)
### 参数

- `value`
- : 被检测的值
- : 要检查的值

### 返回值

- `true`
- : 如果提供的参数是一种 {{jsxref("ArrayBuffer")}} 视图;
- `false`
- : 提供的参数不是一种 {{jsxref("ArrayBuffer")}} 视图类型;
如果给定参数是 {{jsxref("ArrayBuffer")}} 视图之一则返回 `true`;否则返回 `false`。

## 示例

### 使用 isView

```js
ArrayBuffer.isView(); // false
ArrayBuffer.isView([]); // false
Expand All @@ -41,8 +40,8 @@ ArrayBuffer.isView(new Uint8Array()); // true
ArrayBuffer.isView(new Float32Array()); // true
ArrayBuffer.isView(new Int8Array(10).subarray(0, 3)); // true

var buffer = new ArrayBuffer(2);
var dv = new DataView(buffer);
const buffer = new ArrayBuffer(2);
const dv = new DataView(buffer);
ArrayBuffer.isView(dv); // true
```

Expand All @@ -54,6 +53,6 @@ ArrayBuffer.isView(dv); // true

{{Compat}}

## 另见
## 参见

- [JavaScript typed arrays](/zh-CN/docs/Web/JavaScript/Typed_arrays)
- [JavaScript 类型化数组](/zh-CN/docs/Web/JavaScript/Guide/Typed_arrays)指南