aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/global_objects/arraybuffer/isview/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-cn/web/javascript/reference/global_objects/arraybuffer/isview/index.html')
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/arraybuffer/isview/index.html87
1 files changed, 87 insertions, 0 deletions
diff --git a/files/zh-cn/web/javascript/reference/global_objects/arraybuffer/isview/index.html b/files/zh-cn/web/javascript/reference/global_objects/arraybuffer/isview/index.html
new file mode 100644
index 0000000000..2b545d9c03
--- /dev/null
+++ b/files/zh-cn/web/javascript/reference/global_objects/arraybuffer/isview/index.html
@@ -0,0 +1,87 @@
+---
+title: ArrayBuffer.isView()
+slug: Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView
+tags:
+ - 类型数组
+ - 缓冲区
+translation_of: Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView
+---
+<div>{{JSRef}}</div>
+
+<p><code><strong>ArrayBuffer.isView()</strong></code> 方法用来判断传入的参数值是否是一种 <code>ArrayBuffer</code> 视图(view),比如类型化数组对象(<a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray">typed array objects</a>)或者数据视图( {{jsxref("DataView")}})。</p>
+
+<div>{{EmbedInteractiveExample("pages/js/arraybuffer-isview.html")}}</div>
+
+
+
+<h2 id="语法">语法</h2>
+
+<pre class="brush: js"><code>ArrayBuffer.isView(<var>value</var>)</code></pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><code>value</code></dt>
+ <dd>被检测的值。</dd>
+</dl>
+
+<h3 id="返回值">返回值</h3>
+
+<dl>
+ <dt><code>true</code></dt>
+ <dd>如果提供的参数是一种 {{jsxref("ArrayBuffer")}} 视图;</dd>
+ <dt><code>false</code></dt>
+ <dd>提供的参数不是一种 {{jsxref("ArrayBuffer")}} 视图类型;</dd>
+</dl>
+
+<h2 id="示例">示例</h2>
+
+<pre class="brush: js">ArrayBuffer.isView(); // false
+ArrayBuffer.isView([]); // false
+ArrayBuffer.isView({}); // false
+ArrayBuffer.isView(null); // false
+ArrayBuffer.isView(undefined); // false
+ArrayBuffer.isView(new ArrayBuffer(10)); // false
+
+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);
+ArrayBuffer.isView(dv); // true
+</pre>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('Typed Array')}}</td>
+ <td>{{Spec2('Typed Array')}}</td>
+ <td>Superseded by ECMAScript 6.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES6', '#sec-arraybuffer.isview', 'ArrayBuffer.isView')}}</td>
+ <td>{{Spec2('ES6')}}</td>
+ <td>Initial definition in an ECMA standard.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+
+
+<p>{{Compat("javascript.builtins.ArrayBuffer.isView")}}</p>
+
+<h2 id="另见">另见</h2>
+
+<ul>
+ <li><a href="/en-US/docs/Web/JavaScript/Typed_arrays" title="en/JavaScript typed arrays">JavaScript typed arrays</a></li>
+</ul>