mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-12-15 07:06:53 +08:00
语法高亮,滚动条美化,设置页面调整
This commit is contained in:
@@ -2,14 +2,14 @@
|
||||
<div></div>
|
||||
<p><code><strong>Array.of()</strong></code> 方法创建一个具有可变数量参数的新数组实例,而不考虑参数的数量或类型。</p>
|
||||
<p> <code><strong>Array.of()</strong></code> 和 <code><strong>Array</strong></code> 构造函数之间的区别在于处理整数参数:<code><strong>Array.of(7)</strong></code><strong> </strong>创建一个具有单个元素 <strong>7</strong> 的数组,而 <strong><code>Array(7)</code> </strong>创建一个长度为7的空数组(<strong>注意:</strong>这是指一个有7个空位(empty)的数组,而不是由7个<code>undefined</code>组成的数组)。</p>
|
||||
<pre class="brush: js">Array.of(7); // [7]
|
||||
<pre><code class="language-javascript">Array.of(7); // [7]
|
||||
Array.of(1, 2, 3); // [1, 2, 3]
|
||||
|
||||
Array(7); // [ , , , , , , ]
|
||||
Array(1, 2, 3); // [1, 2, 3]
|
||||
</pre>
|
||||
</code></pre>
|
||||
<h2 id="Syntax" name="Syntax">语法</h2>
|
||||
<pre class="syntaxbox"><code>Array.of(<var>element0</var>[, <var>element1</var>[, ...[, <var>elementN</var>]]])</code></pre>
|
||||
<pre><code class="language-javascript"><code>Array.of(<var>element0</var>[, <var>element1</var>[, ...[, <var>elementN</var>]]])</code></code></pre>
|
||||
<h3 id="Parameters" name="Parameters">参数</h3>
|
||||
<dl>
|
||||
<dt>element<em>N</em></dt>
|
||||
@@ -20,17 +20,17 @@ Array(1, 2, 3); // [1, 2, 3]
|
||||
<h2 id="描述">描述</h2>
|
||||
<p>此函数是ECMAScript 2015标准的一部分。详见 <a class="external" href="https://gist.github.com/rwaldron/1074126" rel="noopener"><code>Array.of 和</code> <code>Array.from</code> proposal</a> 和 <a class="external" href="https://gist.github.com/rwaldron/3186576" rel="noopener"><code>Array.of</code> polyfill</a>。</p>
|
||||
<h2 id="示例">示例</h2>
|
||||
<pre class="brush: js" style="font-size: 14px;"><span style="line-height: 22px;">Array.of(1); // [1]
|
||||
<pre><code class="language-js" style="font-size: 14px;"><span style="line-height: 22px;">Array.of(1); // [1]
|
||||
</span><span style="line-height: 22px;">Array.of(1, 2, 3); // [1, 2, 3]</span>
|
||||
Array.of(undefined); // [undefined]
|
||||
</pre>
|
||||
</code></pre>
|
||||
<h2 id="Compatibility" name="Compatibility">兼容旧环境</h2>
|
||||
<p>如果原生不支持的话,在其他代码之前执行以下代码会创建 <code>Array.of()</code> 。</p>
|
||||
<pre class="brush: js" style="font-size: 14px;">if (!Array.of) {
|
||||
<pre><code class="language-js" style="font-size: 14px;">if (!Array.of) {
|
||||
Array.of = function() {
|
||||
return Array.prototype.slice.call(arguments);
|
||||
};
|
||||
}</pre>
|
||||
}</code></pre>
|
||||
<h2 id="规范">规范</h2>
|
||||
<table class="standard-table">
|
||||
<tbody>
|
||||
|
||||
Reference in New Issue
Block a user