aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/global_objects/sharedarraybuffer/bytelength/index.html
blob: a5586230147736d5381c179c98f52e044344bc0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
---
title: SharedArrayBuffer.prototype.byteLength
slug: Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/byteLength
tags:
  - SharedArrayBuffer
translation_of: Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/byteLength
---
<div>{{JSRef}}</div>

<p> <code><strong>byteLength</strong></code> 访问器属性表示以字节为单位的一个{{jsxref("SharedArrayBuffer")}}的长度。</p>

<h2 id="语法">语法</h2>

<pre class="syntaxbox"><var>sab</var>.byteLength</pre>

<h2 id="描述">描述</h2>

<p><code>byteLength</code>属性是一个访问者属性,其set访问者函数为 <code>undefined</code>,这意味着您只能读取此属性。 该值在构造共享数组时建立,并且无法更改。</p>

<h2 id="例子">例子</h2>

<pre class="brush:js">var sab = new SharedArrayBuffer(1024);
sab.byteLength; // 1024
</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('ESDraft', '#sec-get-sharedarraybuffer.prototype.bytelength', 'SharedArrayBuffer.prototype.byteLength')}}</td>
   <td>{{Spec2('ESDraft')}}</td>
   <td>Initial definition in ES2017.</td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器兼容性">浏览器兼容性</h2>



<p>{{Compat("javascript.builtins.SharedArrayBuffer.byteLength")}}</p>

<h2 id="相关链接">相关链接</h2>

<ul>
 <li>{{jsxref("SharedArrayBuffer")}}</li>
</ul>