语法高亮,滚动条美化,设置页面调整

This commit is contained in:
fofolee
2019-04-19 02:41:09 +08:00
parent 1e8f76c000
commit 359d29ee0b
1590 changed files with 12328 additions and 11441 deletions

View File

@@ -2,11 +2,11 @@
<div></div>
<p><strong><code>Uint8Array</code></strong> 数组类型表示一个8位无符号整型数组创建时内容被初始化为0。创建完后可以以对象的方式或使用数组下标索引的方式引用数组中的元素。</p>
<h2 id="语法格式">语法格式</h2>
<pre class="syntaxbox">new Uint8Array(); // ES2017 最新语法
<pre><code class="language-javascript">new Uint8Array(); // ES2017 最新语法
new Uint8Array(length); // 创建初始化为0的包含length个元素的无符号整型数组
new Uint8Array(typedArray);
new Uint8Array(object);
new Uint8Array(buffer [, byteOffset [, length]]);</pre>
new Uint8Array(buffer [, byteOffset [, length]]);</code></pre>
<p>构造语法和参数的更多信息请参见 <em><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#Syntax">TypedArray</a></em>.</p>
<h2 id="属性">属性</h2>
<dl>
@@ -99,7 +99,7 @@ new Uint8Array(buffer [, byteOffset [, length]]);</pre>
<dd><code>返回新的 Array Iterator</code> 对象,包含数组中每个下标处的值。</dd>
</dl>
<h2 id="例子">例子</h2>
<pre class="brush: js">// 来自长度
<pre><code class="language-javascript">// 来自长度
var uint8 = new Uint8Array(2);
uint8[0] = 42;
console.log(uint8[0]); // 42
@@ -124,7 +124,7 @@ var iterable = function*(){ yield* [1,2,3]; }();
var uint8 = new Uint8Array(iterable);
// Uint8Array[1, 2, 3]
</pre>
</code></pre>
<h2 id="规范">规范</h2>
<table class="standard-table">
<tbody>
@@ -300,10 +300,10 @@ var uint8 = new Uint8Array(iterable);
</abbr></span></dt><dd>Compatibility unknown</dd></dl></section></div><p></p>
<h2 id="兼容性说明">兼容性说明</h2>
<p>从 ECMAScript 2015 开始,<code>Uint8Array</code> 构造函数需要通过 <a href="Reference/Operators/new" title="new 运算符创建一个用户定义的对象类型的实例或具有构造函数的内置对象的实例。"><code>new</code></a> 操作符调用。即日起如果没有使用 <code>new</code> 调用 <code>Uint8Array</code> 的构造函数,将会抛出 <a href="Reference/Global_Objects/TypeError" title="TypeError类型错误 对象用来表示值的类型非预期类型时发生的错误。"><code>TypeError</code></a></p>
<pre class="brush: js example-bad">var dv = Uint8Array([1, 2, 3]);
<pre><code class="language-js example-bad">var dv = Uint8Array([1, 2, 3]);
// TypeError: calling a builtin Uint8Array constructor
// 不使用 new 将会被禁止</pre>
<pre class="brush: js example-good">var dv = new Uint8Array([1, 2, 3]);</pre>
// 不使用 new 将会被禁止</code></pre>
<pre><code class="language-js example-good">var dv = new Uint8Array([1, 2, 3]);</code></pre>
<h2 id="相关内容">相关内容</h2>
<ul>
<li><a href="/en-US/docs/Web/JavaScript/Typed_arrays" title="en/JavaScript typed arrays">JavaScript 类型化数组</a></li>