mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-12-16 07:51:52 +08:00
语法高亮,滚动条美化,设置页面调整
This commit is contained in:
@@ -36,20 +36,20 @@
|
||||
<h2 id="示例">示例</h2>
|
||||
<h3 id="自定义迭代器">自定义迭代器</h3>
|
||||
<p>我们可以像下面这样创建自定义的迭代器:</p>
|
||||
<pre class="brush: js">var myIterable = {}
|
||||
<pre><code class="language-javascript">var myIterable = {}
|
||||
myIterable[Symbol.iterator] = function* () {
|
||||
yield 1;
|
||||
yield 2;
|
||||
yield 3;
|
||||
};
|
||||
[...myIterable] // [1, 2, 3]
|
||||
</pre>
|
||||
</code></pre>
|
||||
<h3 id="不符合标准的迭代器">不符合标准的迭代器</h3>
|
||||
<p>如果一个迭代器 <code>@@iterator</code> 没有返回一个迭代器对象,那么它就是一个不符合标准的迭代器,这样的迭代器将会在运行期抛出异常,甚至非常诡异的 Bug。</p>
|
||||
<pre class="brush: js">var nonWellFormedIterable = {}
|
||||
<pre><code class="language-javascript">var nonWellFormedIterable = {}
|
||||
nonWellFormedIterable[Symbol.iterator] = () => 1
|
||||
[...nonWellFormedIterable] // TypeError: [] is not a function
|
||||
</pre>
|
||||
</code></pre>
|
||||
<h2 id="规范">规范</h2>
|
||||
<table class="standard-table">
|
||||
<tbody>
|
||||
|
||||
Reference in New Issue
Block a user