aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/global_objects/bigint64array/index.html
blob: 566ba9e61ee8f8b89574428abc55946e7aca2215 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
---
title: BigInt64Array
slug: Web/JavaScript/Reference/Global_Objects/BigInt64Array
translation_of: Web/JavaScript/Reference/Global_Objects/BigInt64Array
---
<div>
<p>{{JSRef}}</p>

<p><strong><code>BigInt64Array</code></strong> 类型的数组代表由64位有符号整数组成的数组。如果需要控制字节顺序的话,请使用 {{jsxref("DataView")}} 代替。内容初始化为 <code>0n</code> 。一旦建立,就可以使用对象的方法或使用标准数组索引语法(即使用中括号表示法)引用数组中的元素。</p>
</div>

<h2 id="构造函数">构造函数</h2>

<p><a href="/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/BigInt64Array/BigInt64Array"><code>BigInt64Array()</code></a></p>

<p>     添加一个新的<code>BigInt64Array</code>对象。</p>

<h2 id="静态属性">静态属性</h2>

<dl>
 <dt>{{jsxref("TypedArray.BYTES_PER_ELEMENT", "BigInt64Array.BYTES_PER_ELEMENT")}}</dt>
</dl>

<p>   返回一个元素大小的数字值,<code>BigInt64Array</code>返回 <code>8</code></p>

<dl>
 <dt>{{jsxref("TypedArray.name", "BigInt64Array.name")}}</dt>
</dl>

<p>   返回构造函数名字的字符串值,如果是<code>BigInt64Array</code> 的话,就是"BigInt64Array".</p>

<h2 id="实例属性">实例属性</h2>

<dl>
 <dt>{{jsxref("TypedArray.prototype.buffer", "BigInt64Array.prototype.buffer")}}</dt>
 <dd>返回被<code>BigInt64Array</code>引用的{{jsxref("ArrayBuffer")}} 。这在BigInt64Array对象构建时期就被锁定了,所以是只读的。</dd>
 <dt>{{jsxref("TypedArray.prototype.byteLength", "BigInt64Array.prototype.byteLength")}}</dt>
 <dd>返回<code>BigInt64Array</code>从{jsxref(“ArrayBuffer”)}}开始的长度(以字节为单位)。这在构造时已经被固定,因此是只读的。</dd>
 <dt>{{jsxref("TypedArray.prototype.byteOffset", "BigInt64Array.prototype.byteOffset")}}</dt>
 <dd>返回 <code>BigInt64Array</code> 从{jsxref(“ArrayBuffer”)}}开始的偏移量(以字节为单位)。这在构造时已被固定的,因此是只读。</dd>
 <dt>{{jsxref("TypedArray.prototype.length", "BigInt64Array.prototype.length")}}</dt>
 <dd>                
 <p>返回 <code>BigInt64Array</code> 中被 保留的元 素个数。这  在构造时是固定的,因此是只读 。  <strong> </strong></p>
 </dd>
</dl>

<h2 id="实例方法">实例方法</h2>

<dl>
 <dt>{{jsxref("TypedArray.copyWithin", "BigInt64Array.prototype.copyWithin()")}}</dt>
 <dd>复制数组中的数组元素序列。另请参见{jsxref(“Array.prototype.copyWithin()")}}.</dd>
 <dt>{{jsxref("TypedArray.entries", "BigInt64Array.prototype.entries()")}}</dt>
 <dd>返回一个新的数组迭代器对象,该对象包含数组中每个索引的键/值对。另请参见{jsxref(“Array.prototype.entries()")}}.</dd>
 <dt>{{jsxref("TypedArray.every", "BigInt64Array.prototype.every()")}}</dt>
 <dd>测试数组中的所有元素是否通过函数提供的测试。另请参见{jsxref(“Array.prototype.every()")}}.</dd>
 <dt>{{jsxref("TypedArray.fill", "BigInt64Array.prototype.fill()")}}</dt>
 <dd>
 <div class="trans-left">
 <div class="trans-input-wrap">
 <div class="input-wrap" dir="ltr">用静态值填充从起始索引到结束索引的数组的所有元素。另请参见{jsxref(“Array.prototype.fill()")}}</div>
 </div>
 </div>
 </dd>
 <dt>{{jsxref("TypedArray.filter", "BigInt64Array.prototype.filter()")}}</dt>
 <dd>使用提供的筛选函数为其返回true的数组的所有元素创建一个新数组。另请参见{jsxref(“Array.prototype.filter()")}}</dd>
 <dt>{{jsxref("TypedArray.find", "BigInt64Array.prototype.find()")}}</dt>
 <dd>如果数组中的元素满足提供的测试函数,则返回数组中找到的值;如果未找到,则返回 <code>undefined</code> 。另请参见{jsxref(“Array.prototype.find()")}}.</dd>
 <dt>{{jsxref("TypedArray.findIndex", "BigInt64Array.prototype.findIndex()")}}</dt>
 <dd>如果数组中的元素满足提供的测试函数,则返回数组中找到的索引;如果未找到,则返回-1。另请参见{jsxref(“Array.prototype.findIndex()")}}.</dd>
 <dt>{{jsxref("TypedArray.forEach", "BigInt64Array.prototype.forEach()")}}</dt>
 <dd>为数组中的每个元素调用函数。另请参见{jsxref(“Array.prototype.forEach()")}}</dd>
 <dt>{{jsxref("TypedArray.includes", "BigInt64Array.prototype.includes()")}}</dt>
 <dd>确定类型化数组是否包含某个元素,并根据需要返回 <code>true</code><code>false</code> 。另请参见{jsxref(“Array.prototype.includes()")}}.</dd>
 <dt>{{jsxref("TypedArray.indexOf", "BigInt64Array.prototype.indexOf()")}}</dt>
 <dd>返回数组中元素的第一个(最小)索引,等于指定值;如果找不到,则返回-1。另请参见{jsxref(“Array.prototype.indexOf()")}}</dd>
 <dt>{{jsxref("TypedArray.join", "BigInt64Array.prototype.join()")}}</dt>
 <dd>将数组的所有元素联接为字符串。另请参见{jsxref(“Array.prototype.join()")}}</dd>
 <dt>{{jsxref("TypedArray.keys", "BigInt64Array.prototype.keys()")}}</dt>
 <dd>返回一个新的 <code>Array Iterator</code> ,它包含数组中每个索引的键。另请参见{jsxref(“Array.prototype.keys()")}}.</dd>
 <dt>{{jsxref("TypedArray.lastIndexOf", "BigInt64Array.prototype.lastIndexOf()")}}</dt>
 <dd>返回数组中元素的最后一个(最大)索引,等于指定值;如果找不到,则返回-1。另请参见{jsxref(“Array.prototype.lastIndexOf()")}}.</dd>
 <dt>{{jsxref("TypedArray.map", "BigInt64Array.prototype.map()")}}</dt>
 <dd>创建一个新数组,其中包含对此数组中的每个元素调用所提供函数的结果。另请参见{jsxref(“Array.prototype.map()")}}.</dd>
 <dt>{{jsxref("TypedArray.reduce", "BigInt64Array.prototype.reduce()")}}</dt>
 <dd>对累加器和数组的每个值(从左到右)应用一个函数,以便将其减少为单个值。另请参见{jsxref(“Array.prototype.reduce()")}}.</dd>
 <dt>{{jsxref("TypedArray.reduceRight", "BigInt64Array.prototype.reduceRight()")}}</dt>
 <dd>对累加器和数组的每个值(从右到左)应用一个函数,以便将其减少为单个值。另请参见{jsxref(“Array.prototype.reduceRight()")}}.</dd>
 <dt>{{jsxref("TypedArray.reverse", "BigInt64Array.prototype.reverse()")}}</dt>
 <dd>反转数组元素的顺序-第一个变为最后一个,最后一个变为第一个。另请参见{jsxref(“Array.prototype.reverse()")}}.</dd>
 <dt>{{jsxref("TypedArray.set", "BigInt64Array.prototype.set()")}}</dt>
 <dd>在 typed array 中存储多个值,从指定数组读取输入值。</dd>
 <dt>{{jsxref("TypedArray.slice", "BigInt64Array.prototype.slice()")}}</dt>
 <dd>提取数组的一部分并返回一个新数组。另请参见{jsxref(“Array.prototype.slice()")}}.</dd>
 <dt>{{jsxref("TypedArray.some", "BigInt64Array.prototype.some()")}}</dt>
 <dd>如果此数组中至少有一个元素满足提供的测试函数,则返回true。另请参见{jsxref(“Array.prototype.some()")}}.</dd>
 <dt>{{jsxref("TypedArray.sort", "BigInt64Array.prototype.sort()")}}</dt>
 <dd>对数组的元素进行就地排序并返回数组。另请参见{jsxref(“Array.prototype.sort()")}}.</dd>
 <dt>{{jsxref("TypedArray.subarray", "BigInt64Array.prototype.subarray()")}}</dt>
 <dd>从给定的起始和结束元素索引返回一个新的 <code>BigUint64Array</code></dd>
 <dt>{{jsxref("TypedArray.values", "BigInt64Array.prototype.values()")}}</dt>
 <dd>返回一个新的 <code>Array Iterator</code> 对象,该对象包含数组中每个索引的值。另请参见{jsxref(“Array.prototype.values()")}}.</dd>
 <dt>{{jsxref("TypedArray.toLocaleString", "BigInt64Array.prototype.toLocaleString()")}}</dt>
 <dd>返回表示数组及其元素的本地化字符串。另请参见{jsxref(“Array.prototype.toLocaleString()")}}.</dd>
 <dt>{{jsxref("TypedArray.toString", "BigInt64Array.prototype.toString()")}}</dt>
 <dd>返回表示数组及其元素的字符串。另请参见{jsxref(“Array.prototype.toString()")}}.</dd>
 <dt>{{jsxref("TypedArray.@@iterator", "BigInt64Array.prototype[@@iterator]()")}}</dt>
 <dd>返回一个新的 <code>Array Iterator</code> 对象,该对象包含数组中每个索引的值。</dd>
</dl>

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

<h3 id="不同的方法去创建一个_BigInt64Array">不同的方法去创建一个 <code>BigInt64Array</code></h3>

<pre class="brush: js">// From a length
var bigint64 = new BigInt64Array(2);
bigint64[0] = 42n;
console.log(bigint64[0]); // 42n
console.log(bigint64.length); // 2
console.log(bigint64.BYTES_PER_ELEMENT); // 8

// From an array
var arr = new BigInt64Array([21n,31n]);
console.log(arr[1]); // 31n

// From another TypedArray
var x = new BigInt64Array([21n, 31n]);
var y = new BigInt64Array(x);
console.log(y[0]); // 21n

// From an ArrayBuffer
var buffer = new ArrayBuffer(32);
var z = new BigInt64Array(buffer, 0, 4);

// From an iterable
var iterable = function*(){ yield* [1n, 2n, 3n]; }();
var bigint64 = new BigInt64Array(iterable);
// BigInt64Array[1n, 2n, 3n]</pre>

<h2 id="规格">规格</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>
    <p>{{SpecName("ESDraft", "#sec-typedarray-objects", "BigInt64Array")}}</p>
   </td>
  </tr>
 </tbody>
</table>

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



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

<h2 id="参考">参考</h2>

<ul>
 <li><a href="/zh-CN/docs/Web/JavaScript/Typed_arrays" title="en/JavaScript typed arrays">JavaScript typed arrays</a></li>
 <li>{{jsxref("BigUint64Array")}}</li>
 <li>{{jsxref("DataView")}}</li>
</ul>