--- title: ArrayBuffer.prototype.byteLength slug: Web/JavaScript/Reference/Global_Objects/ArrayBuffer/byteLength translation_of: Web/JavaScript/Reference/Global_Objects/ArrayBuffer/byteLength --- <div>{{JSRef}}</div> <p><code><strong>byteLength</strong>访问器属性</code>表示一个{{jsxref("ArrayBuffer")}} 对象的字节长度。</p> <div>{{EmbedInteractiveExample("pages/js/arraybuffer-bytelength.html")}}</div> <h2 id="语法">语法</h2> <pre class="syntaxbox"><var>arr</var>aybuffer.byteLength</pre> <h2 id="描述">描述</h2> <p>byteLength属性是一个访问器属性,它的set访问器函数是undefined,这意味着你只能读这个属性。 该值在数组创建时确定,并且不可变更。如果这个<code>ArrayBuffer</code> 被移除,则此属性返回0。</p> <p> </p> <h2 id="示例">示例</h2> <pre class="brush:js">var buffer = new ArrayBuffer(8); buffer.byteLength; // 8 </pre> <h2 id="规范">规范</h2> <table class="standard-table"> <tbody> <tr> <th scope="col">规范</th> <th scope="col">状态</th> <th scope="col">备注</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-get-arraybuffer.prototype.bytelength', 'ArrayBuffer.prototype.byteLength')}}</td> <td>{{Spec2('ES6')}}</td> <td>Initial definition in an ECMA standard.</td> </tr> </tbody> </table> <h2 id="浏览器兼容性">浏览器兼容性</h2> <p>{{Compat("javascript.builtins.ArrayBuffer.byteLength")}}</p> <h2 id="相关链接">相关链接</h2> <ul> <li>{{jsxref("ArrayBuffer")}}</li> </ul>