mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-12-16 07:51:52 +08:00
语法高亮,滚动条美化,设置页面调整
This commit is contained in:
@@ -2,10 +2,10 @@
|
||||
<div></div>
|
||||
<p>The <strong><code>Int16Array</code></strong> typed array represents an array of twos-complement 16-bit signed integers in the platform byte order. If control over byte order is needed, use <a href="Reference/Global_Objects/DataView" title="DataView 视图是一个可以从 ArrayBuffer 对象中读写多种数值类型的底层接口,在读写时不用考虑平台字节序问题。"><code>DataView</code></a> instead. The contents are initialized to <code>0</code>. Once established, you can reference elements in the array using the object's methods, or using standard array index syntax (that is, using bracket notation).</p>
|
||||
<h2 id="语法">语法</h2>
|
||||
<pre class="syntaxbox">new Int16Array(length);
|
||||
<pre><code class="language-javascript">new Int16Array(length);
|
||||
new Int16Array(typedArray);
|
||||
new Int16Array(object);
|
||||
new Int16Array(buffer [, byteOffset [, length]]);</pre>
|
||||
new Int16Array(buffer [, byteOffset [, length]]);</code></pre>
|
||||
<p>For more information about the constructor syntax and the parameters, see <em><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#Syntax">TypedArray</a></em>.</p>
|
||||
<h2 id="属性">属性</h2>
|
||||
<dl>
|
||||
@@ -98,7 +98,7 @@ new Int16Array(buffer [, byteOffset [, length]]);</pre>
|
||||
<dd>Returns a new <code>Array Iterator</code> object that contains the values for each index in the array.</dd>
|
||||
</dl>
|
||||
<h2 id="Examples">Examples</h2>
|
||||
<pre class="brush: js">// From a length
|
||||
<pre><code class="language-javascript">// From a length
|
||||
var int16 = new Int16Array(2);
|
||||
int16[0] = 42;
|
||||
console.log(int16[0]); // 42
|
||||
@@ -117,7 +117,7 @@ console.log(y[0]); // 21
|
||||
// From an ArrayBuffer
|
||||
var buffer = new ArrayBuffer(8);
|
||||
var z = new Int16Array(buffer, 0, 4);
|
||||
</pre>
|
||||
</code></pre>
|
||||
<h2 id="Specifications">Specifications</h2>
|
||||
<table class="standard-table">
|
||||
<tbody>
|
||||
@@ -220,10 +220,10 @@ var z = new Int16Array(buffer, 0, 4);
|
||||
</div>
|
||||
<h2 id="Compatibility_notes">Compatibility notes</h2>
|
||||
<p>Starting with ECMAScript 2015, <code>Int16Array</code> constructors require to be constructed with a <a href="Reference/Operators/new" title="new 运算符创建一个用户定义的对象类型的实例或具有构造函数的内置对象的实例。"><code>new</code></a> operator. Calling a <code>Int16Array</code> constructor as a function without <code>new</code>, will throw a <a href="Reference/Global_Objects/TypeError" title="TypeError(类型错误) 对象用来表示值的类型非预期类型时发生的错误。"><code>TypeError</code></a> from now on.</p>
|
||||
<pre class="brush: js example-bad">var dv = Int16Array([1, 2, 3]);
|
||||
<pre><code class="language-js example-bad">var dv = Int16Array([1, 2, 3]);
|
||||
// TypeError: calling a builtin Int16Array constructor
|
||||
// without new is forbidden</pre>
|
||||
<pre class="brush: js example-good">var dv = new Int16Array([1, 2, 3]);</pre>
|
||||
// without new is forbidden</code></pre>
|
||||
<pre><code class="language-js example-good">var dv = new Int16Array([1, 2, 3]);</code></pre>
|
||||
<h2 id="See_also">See also</h2>
|
||||
<ul>
|
||||
<li><a href="/en-US/docs/Web/JavaScript/Typed_arrays" title="en/JavaScript typed arrays">JavaScript typed arrays</a></li>
|
||||
|
||||
Reference in New Issue
Block a user