diff options
Diffstat (limited to 'files/zh-cn/web/javascript/reference/global_objects/dataview/bytelength/index.html')
-rw-r--r-- | files/zh-cn/web/javascript/reference/global_objects/dataview/bytelength/index.html | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/files/zh-cn/web/javascript/reference/global_objects/dataview/bytelength/index.html b/files/zh-cn/web/javascript/reference/global_objects/dataview/bytelength/index.html new file mode 100644 index 0000000000..a581506c44 --- /dev/null +++ b/files/zh-cn/web/javascript/reference/global_objects/dataview/bytelength/index.html @@ -0,0 +1,70 @@ +--- +title: DataView.prototype.byteLength +slug: Web/JavaScript/Reference/Global_Objects/DataView/byteLength +translation_of: Web/JavaScript/Reference/Global_Objects/DataView/byteLength +--- +<div>{{JSRef}}</div> + +<p> <strong><code>byteLength</code></strong> 属性描述了视图从它的 {{jsxref("ArrayBuffer")}} 开始的字节长度。</p> + +<div>{{EmbedInteractiveExample("pages/js/dataview-bytelength.html")}}</div> + + + +<h2 id="语法">语法</h2> + +<pre class="syntaxbox"><var>dataview</var>.byteLength</pre> + +<h2 id="描述">描述</h2> + +<p><code>byteLength</code> 属性是一个获取(accessor)属性,它的 set 属性为 undefined,这意味着它是只读的。值在 <code>DataView 被创建时就确定了,且不能改变。如果</code> <code>DataView</code> 没有指定偏移量或byteLength,那么被引用的 <code>ArrayBuffer 的字节长度将被返回。</code></p> + +<h2 id="Examples">Examples</h2> + +<h3 id="Using_the_byteLength_property">Using the <code>byteLength</code> property</h3> + +<pre class="brush:js">var buffer = new ArrayBuffer(8); +var dataview = new DataView(buffer); +dataview.byteLength; // 8 (matches the byteLength of the buffer) + +var dataview2 = new DataView(buffer, 1, 5); +dataview2.byteLength; // 5 (as specified when constructing the DataView) + +var dataview3 = new DataView(buffer, 2); +dataview3.byteLength; // 6 (due to the offset of the constructed DataView) +</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('ES6', '#sec-get-dataview.prototype.bytelength', 'DataView.prototype.byteLength')}}</td> + <td>{{Spec2('ES6')}}</td> + <td>Initial definition.</td> + </tr> + <tr> + <td>{{SpecName('ESDraft', '#sec-get-dataview.prototype.bytelength', 'DataView.prototype.byteLength')}}</td> + <td>{{Spec2('ESDraft')}}</td> + <td> </td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + + + +<p>{{Compat("javascript.builtins.DataView.byteLength")}}</p> + +<h2 id="相关链接">相关链接</h2> + +<ul> + <li>{{jsxref("DataView")}}</li> + <li>{{jsxref("ArrayBuffer")}}</li> +</ul> |