mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-12-17 08:26:32 +08:00
语法高亮,滚动条美化,设置页面调整
This commit is contained in:
@@ -4,12 +4,12 @@
|
||||
<div><iframe class="interactive interactive-js" frameborder="0" height="250" src="https://interactive-examples.mdn.mozilla.net/pages/js/map-prototype-@@iterator.html" width="100%"></iframe></div>
|
||||
<p class="hidden">The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone <a class="external" href="https://github.com/mdn/interactive-examples" rel="noopener">https://github.com/mdn/interactive-examples</a> and send us a pull request.</p>
|
||||
<h2 id="语法">语法</h2>
|
||||
<pre class="syntaxbox"><code><em>myMap</em>[Symbol.iterator]</code></pre>
|
||||
<pre><code class="language-javascript"><code><em>myMap</em>[Symbol.iterator]</code></code></pre>
|
||||
<h3 id="返回值">返回值</h3>
|
||||
<p>map 的 <strong>iterator</strong> 函数默认就是 <a href="Reference/Global_Objects/Map/entries" title="entries() ?方法返回一个新的包含 [key, value] ?对的 Iterator ?对象,返回的迭代器的迭代顺序与 Map 对象的插入顺序相同。"><code>entries()</code></a> 函数。</p>
|
||||
<h2 id="示例">示例</h2>
|
||||
<h3 id="使用_iterator()">使用 <code>[@@iterator]()</code></h3>
|
||||
<pre class="brush:js">var myMap = new Map();
|
||||
<pre><code class="language-js">var myMap = new Map();
|
||||
myMap.set('0', 'foo');
|
||||
myMap.set(1, 'bar');
|
||||
myMap.set({}, 'baz');
|
||||
@@ -19,9 +19,9 @@ var mapIter = myMap[Symbol.iterator]();
|
||||
console.log(mapIter.next().value); // ["0", "foo"]
|
||||
console.log(mapIter.next().value); // [1, "bar"]
|
||||
console.log(mapIter.next().value); // [Object, "baz"]
|
||||
</pre>
|
||||
</code></pre>
|
||||
<h3 id="在for..of中使用iterator()">在<code>for..of中</code>使用<code>[@@iterator]()</code> </h3>
|
||||
<pre class="brush:js">var myMap = new Map();
|
||||
<pre><code class="language-js">var myMap = new Map();
|
||||
myMap.set('0', 'foo');
|
||||
myMap.set(1, 'bar');
|
||||
myMap.set({}, 'baz');
|
||||
@@ -39,7 +39,7 @@ for (var v of myMap) {
|
||||
|
||||
// 0: foo
|
||||
// 1: bar
|
||||
// [Object]: baz</pre>
|
||||
// [Object]: baz</code></pre>
|
||||
<h2 id="规范">规范</h2>
|
||||
<table class="standard-table">
|
||||
<tbody>
|
||||
|
||||
@@ -2,18 +2,18 @@
|
||||
<div></div>
|
||||
<p> <code><strong>Map[@@species]</strong></code> 访问器属性会返回一个 <code>Map</code> 构造函数.</p>
|
||||
<h2 id="语法">语法</h2>
|
||||
<pre class="syntaxbox">Map[Symbol.species]
|
||||
</pre>
|
||||
<pre><code class="language-javascript">Map[Symbol.species]
|
||||
</code></pre>
|
||||
<h2 id="描述">描述</h2>
|
||||
<p>The species accessor property returns the default constructor for <code>Map</code> objects. Subclass constructors may over-ride it to change the constructor assignment.</p>
|
||||
<h2 id="案例">案例</h2>
|
||||
<p>The species property returns the default constructor function, which is the <code>Map</code> constructor for <code>Map</code> objects:</p>
|
||||
<pre class="brush: js">Map[Symbol.species]; // function Map()</pre>
|
||||
<pre><code class="language-javascript">Map[Symbol.species]; // function Map()</code></pre>
|
||||
<p>In a derived collection object (e.g. your custom map <code>MyMap</code>), the <code>MyMap</code> species is the <code>MyMap</code> constructor. However, you might want to overwrite this, in order to return parent <code>Map</code> objects in your derived class methods:</p>
|
||||
<pre class="brush: js">class MyMap extends Map {
|
||||
<pre><code class="language-javascript">class MyMap extends Map {
|
||||
// 重写覆盖 MyMap species to the parent Map constructor
|
||||
static get [Symbol.species]() { return Map; }
|
||||
}</pre>
|
||||
}</code></pre>
|
||||
<h2 id="规范">规范</h2>
|
||||
<table class="standard-table">
|
||||
<tbody>
|
||||
|
||||
@@ -23,10 +23,10 @@
|
||||
</tbody>
|
||||
</table></div>
|
||||
<h2 id="语法">语法</h2>
|
||||
<pre class="syntaxbox">Map[Symbol.toStringTag]</pre>
|
||||
<pre><code class="language-javascript">Map[Symbol.toStringTag]</code></pre>
|
||||
<h2 id="示例">示例</h2>
|
||||
<pre class="brush:js">Object.prototype.toString.call(new Map()) // "[object Map]"
|
||||
</pre>
|
||||
<pre><code class="language-js">Object.prototype.toString.call(new Map()) // "[object Map]"
|
||||
</code></pre>
|
||||
<h2 id="规范">规范</h2>
|
||||
<table class="standard-table">
|
||||
<tbody>
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
<div><iframe class="interactive interactive-js" frameborder="0" height="250" src="https://interactive-examples.mdn.mozilla.net/pages/js/map-prototype-clear.html" width="100%"></iframe></div>
|
||||
<p class="hidden">The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone <a class="external" href="https://github.com/mdn/interactive-examples" rel="noopener">https://github.com/mdn/interactive-examples</a> and send us a pull request.</p>
|
||||
<h2 id="语法">语法</h2>
|
||||
<pre class="syntaxbox"><code><em>myMap</em>.clear();</code>
|
||||
</pre>
|
||||
<pre><code class="language-javascript"><code><em>myMap</em>.clear();</code>
|
||||
</code></pre>
|
||||
<h3 id="返回值">返回值</h3>
|
||||
<p><a href="Reference/Global_Objects/undefined" title="undefined是全局对象的一个属性。也就是说,它是全局作用域的一个变量。undefined的最初值就是原始数据类型undefined。"><code>undefined</code></a>.</p>
|
||||
<h2 id="示例">示例</h2>
|
||||
<h3 id="调用clear方法">调用<code>clear</code>方法</h3>
|
||||
<pre class="brush: js">var myMap = new Map();
|
||||
<pre><code class="language-javascript">var myMap = new Map();
|
||||
myMap.set("bar", "baz");
|
||||
myMap.set(1, "foo");
|
||||
|
||||
@@ -21,7 +21,7 @@ myMap.clear();
|
||||
|
||||
myMap.size; // 0
|
||||
myMap.has("bar") // false
|
||||
</pre>
|
||||
</code></pre>
|
||||
<h2 id="规范">规范</h2>
|
||||
<table class="standard-table">
|
||||
<tbody>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<div><iframe class="interactive interactive-js" frameborder="0" height="250" src="https://interactive-examples.mdn.mozilla.net/pages/js/map-prototype-delete.html" width="100%"></iframe></div>
|
||||
<p class="hidden">The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone <a class="external" href="https://github.com/mdn/interactive-examples" rel="noopener">https://github.com/mdn/interactive-examples</a> and send us a pull request.</p>
|
||||
<h2 id="语法">语法</h2>
|
||||
<pre class="brush: js">myMap.delete(key);</pre>
|
||||
<pre><code class="language-javascript">myMap.delete(key);</code></pre>
|
||||
<h3 id="参数">参数</h3>
|
||||
<dl>
|
||||
<dt>key</dt>
|
||||
@@ -17,12 +17,12 @@
|
||||
</dl>
|
||||
<h2 id="示例">示例</h2>
|
||||
<h3 id="使用_delete_方法">使用 <code>delete</code> 方法</h3>
|
||||
<pre class="brush: js">var myMap = new Map();
|
||||
<pre><code class="language-javascript">var myMap = new Map();
|
||||
myMap.set("bar", "foo");
|
||||
|
||||
myMap.delete("bar"); // 返回 true。成功地移除元素
|
||||
myMap.has("bar"); // 返回 false。"bar" 元素将不再存在于 Map 实例中
|
||||
</pre>
|
||||
</code></pre>
|
||||
<h2 id="规范">规范</h2>
|
||||
<table class="standard-table">
|
||||
<tbody>
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
<div></div>
|
||||
<p><code><strong>entries()</strong></code> ?方法返回一个新的包含 <code>[key, value]</code> ?对的 <code><strong>Iterator</strong></code> ?对象,返回的迭代器的迭代顺序与 <code>Map</code> 对象的插入顺序相同。</p>
|
||||
<h2 id="语法">语法</h2>
|
||||
<pre class="syntaxbox"><code><em>myMap</em>.entries()</code></pre>
|
||||
<pre><code class="language-javascript"><code><em>myMap</em>.entries()</code></code></pre>
|
||||
<h2 id="示例">示例</h2>
|
||||
<h3 id="entries()_的使用"><code>entries() 的使用</code></h3>
|
||||
<pre class="brush:js">var myMap = new Map();
|
||||
<pre><code class="language-js">var myMap = new Map();
|
||||
myMap.set("0", "foo");
|
||||
myMap.set(1, "bar");
|
||||
myMap.set({}, "baz");
|
||||
@@ -15,7 +15,7 @@ var mapIter = myMap.entries();
|
||||
console.log(mapIter.next().value); // ["0", "foo"]
|
||||
console.log(mapIter.next().value); // [1, "bar"]
|
||||
console.log(mapIter.next().value); // [Object, "baz"]
|
||||
</pre>
|
||||
</code></pre>
|
||||
<h2 id="规范">规范</h2>
|
||||
<table class="standard-table">
|
||||
<tbody>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<div></div>
|
||||
<p><code><strong>forEach()</strong></code> 方法将会以插入顺序对 Map 对象中的每一个键值对执行一次参数中提供的回调函数。</p>
|
||||
<h2 id="语法">语法</h2>
|
||||
<pre class="syntaxbox"><code><em>myMap</em>.forEach(<em>callback</em>[, <em>thisArg</em>])</code></pre>
|
||||
<pre><code class="language-javascript"><code><em>myMap</em>.forEach(<em>callback</em>[, <em>thisArg</em>])</code></code></pre>
|
||||
<h3 id="参数">参数</h3>
|
||||
<dl>
|
||||
<dt><code>callback</code></dt>
|
||||
@@ -29,7 +29,7 @@
|
||||
<h2 id="示例">示例</h2>
|
||||
<h3 id="打印一个_Map_对象中的元素">打印一个 <code>Map </code>对象中的元素</h3>
|
||||
<p>下面的代码在一行中打印一个 <code>Map</code> 对象的每一个元素:</p>
|
||||
<pre class="brush:js">function logMapElements(value, key, map) {
|
||||
<pre><code class="language-js">function logMapElements(value, key, map) {
|
||||
console.log("m[" + key + "] = " + value);
|
||||
}
|
||||
Map([["foo", 3], ["bar", {}], ["baz", undefined]]).forEach(logMapElements);
|
||||
@@ -37,7 +37,7 @@ Map([["foo", 3], ["bar", {}], ["baz", undefined]]).forEach(logMapElements);
|
||||
// "m[foo] = 3"
|
||||
// "m[bar] = [object Object]"
|
||||
// "m[baz] = undefined"
|
||||
</pre>
|
||||
</code></pre>
|
||||
<h2 id="规范">规范</h2>
|
||||
<table class="standard-table">
|
||||
<tbody>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<div><iframe class="interactive interactive-js" frameborder="0" height="250" src="https://interactive-examples.mdn.mozilla.net/pages/js/map-prototype-get.html" width="100%"></iframe></div>
|
||||
<p class="hidden">The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone <a class="external" href="https://github.com/mdn/interactive-examples" rel="noopener">https://github.com/mdn/interactive-examples</a> and send us a pull request.</p>
|
||||
<h2 id="语法">语法</h2>
|
||||
<pre class="syntaxbox"><code><em>myMap</em>.get(key);</code></pre>
|
||||
<pre><code class="language-javascript"><code><em>myMap</em>.get(key);</code></code></pre>
|
||||
<h3 id="参数">参数</h3>
|
||||
<dl>
|
||||
<dt>key</dt>
|
||||
@@ -14,12 +14,12 @@
|
||||
<p>返回一个 <code>Map</code> 对象中与指定键相关联的值,如果找不到这个键则返回 <code>undefined</code>。</p>
|
||||
<h2 id="示例">示例</h2>
|
||||
<h3 id="使用_get_方法">使用 <code>get</code> 方法</h3>
|
||||
<pre class="brush: js">var myMap = new Map();
|
||||
<pre><code class="language-javascript">var myMap = new Map();
|
||||
myMap.set("bar", "foo");
|
||||
|
||||
myMap.get("bar"); // 返回 "foo"
|
||||
myMap.get("baz"); // 返回 undefined
|
||||
</pre>
|
||||
</code></pre>
|
||||
<h2 id="规范">规范</h2>
|
||||
<table class="standard-table">
|
||||
<tbody>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div></div>
|
||||
<p>方法<code><strong>has()</strong></code> 返回一个bool值,用来表明map 中是否存在指定元素.</p>
|
||||
<h2 id="语法">语法</h2>
|
||||
<pre class="syntaxbox"><code><em>myMap</em>.has(key);</code></pre>
|
||||
<pre><code class="language-javascript"><code><em>myMap</em>.has(key);</code></code></pre>
|
||||
<h3 id="参数">参数</h3>
|
||||
<dl>
|
||||
<dt>key</dt>
|
||||
@@ -15,12 +15,12 @@
|
||||
</dl>
|
||||
<h2 id="案例">案例</h2>
|
||||
<h3 id="使用has方法">使用has方法</h3>
|
||||
<pre class="brush: js">var myMap = new Map();
|
||||
<pre><code class="language-javascript">var myMap = new Map();
|
||||
myMap.set("bar", "foo");
|
||||
|
||||
myMap.has("bar"); // returns true
|
||||
myMap.has("baz"); // returns false
|
||||
</pre>
|
||||
</code></pre>
|
||||
<h2 id="规范">规范</h2>
|
||||
<table class="standard-table">
|
||||
<tbody>
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
<div><iframe class="interactive interactive-js" frameborder="0" height="250" src="https://interactive-examples.mdn.mozilla.net/pages/js/map-prototype-keys.html" width="100%"></iframe></div>
|
||||
<p class="hidden">The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone <a class="external" href="https://github.com/mdn/interactive-examples" rel="noopener">https://github.com/mdn/interactive-examples</a> and send us a pull request.</p>
|
||||
<h2 id="语法">语法</h2>
|
||||
<pre class="syntaxbox"><code><em>myMap</em>.keys()</code></pre>
|
||||
<pre><code class="language-javascript"><code><em>myMap</em>.keys()</code></code></pre>
|
||||
<h3 id="返回值">返回值</h3>
|
||||
<p>一个新的 <a href="Reference/Map" title="此页面仍未被本地化, 期待您的翻译!"><code>Map</code></a> iterator 对象.</p>
|
||||
<h2 id="例子">例子</h2>
|
||||
<h3 id="使用_keys()">使用 <code>keys()</code></h3>
|
||||
<pre class="brush:js">var myMap = new Map();
|
||||
<pre><code class="language-js">var myMap = new Map();
|
||||
myMap.set("0", "foo");
|
||||
myMap.set(1, "bar");
|
||||
myMap.set({}, "baz");
|
||||
@@ -19,7 +19,7 @@ var mapIter = myMap.keys();
|
||||
console.log(mapIter.next().value); // "0"
|
||||
console.log(mapIter.next().value); // 1
|
||||
console.log(mapIter.next().value); // Object
|
||||
</pre>
|
||||
</code></pre>
|
||||
<h2 id="规范">规范</h2>
|
||||
<table class="standard-table">
|
||||
<tbody>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<div><iframe class="interactive interactive-js" frameborder="0" height="250" src="https://interactive-examples.mdn.mozilla.net/pages/js/map-prototype-set.html" width="100%"></iframe></div>
|
||||
<p class="hidden">The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone <a class="external" href="https://github.com/mdn/interactive-examples" rel="noopener">https://github.com/mdn/interactive-examples</a> and send us a pull request.</p>
|
||||
<h2 id="语法">语法</h2>
|
||||
<pre class="syntaxbox"><code><em>myMap</em>.set(key, value);</code></pre>
|
||||
<pre><code class="language-javascript"><code><em>myMap</em>.set(key, value);</code></code></pre>
|
||||
<h3 id="参数">参数</h3>
|
||||
<dl>
|
||||
<dt>key</dt>
|
||||
@@ -16,7 +16,7 @@
|
||||
<p><code>Map</code> 对象</p>
|
||||
<h2 id="示例">示例</h2>
|
||||
<h3 id="使用_set_方法">使用 <code>set</code> 方法</h3>
|
||||
<pre class="brush: js">var myMap = new Map();
|
||||
<pre><code class="language-javascript">var myMap = new Map();
|
||||
|
||||
// 将一个新元素添加到 Map 对象
|
||||
myMap.set("bar", "foo");
|
||||
@@ -24,14 +24,14 @@ myMap.set(1, "foobar");
|
||||
|
||||
// 在Map对象中更新某个元素的值
|
||||
myMap.set("bar", "baz");
|
||||
</pre>
|
||||
</code></pre>
|
||||
<h3 id="Using_the_set_method_with_chaining">Using the <code>set</code> method with chaining</h3>
|
||||
<p>因为 Set() 方法返回 Map 对象本身,所以你可以像下面这样链式调用它:</p>
|
||||
<pre class="brush: js">// Add new elements to the map with chaining.
|
||||
<pre><code class="language-javascript">// Add new elements to the map with chaining.
|
||||
myMap.set('bar', 'foo')
|
||||
.set(1, 'foobar')
|
||||
.set(2, 'baz');
|
||||
</pre>
|
||||
</code></pre>
|
||||
<h2 id="规范">规范</h2>
|
||||
<table class="standard-table">
|
||||
<tbody>
|
||||
|
||||
@@ -8,13 +8,13 @@
|
||||
<h2 id="描述">描述</h2>
|
||||
<p>size 属性的值是一个整数,表示 Map 对象有多少个键值对。size 是只读属性,用set 方法修改size返回 undefined,即不能改变它的值。</p>
|
||||
<h2 id="示例">示例</h2>
|
||||
<pre class="brush:js">var myMap = new Map();
|
||||
<pre><code class="language-js">var myMap = new Map();
|
||||
myMap.set("a", "alpha");
|
||||
myMap.set("b", "beta");
|
||||
myMap.set("g", "gamma");
|
||||
|
||||
myMap.size // 3
|
||||
</pre>
|
||||
</code></pre>
|
||||
<h2 id="规范">规范</h2>
|
||||
<table class="standard-table">
|
||||
<tbody>
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
<div><code><strong>values()</strong></code> 方法返回一个新的Iterator对象。它包含按顺序插入Map对象中每个元素的value值。</div>
|
||||
<div> </div>
|
||||
<h2 id="语法">语法</h2>
|
||||
<pre class="syntaxbox"><code><em>myMap</em>.values()</code></pre>
|
||||
<pre><code class="language-javascript"><code><em>myMap</em>.values()</code></code></pre>
|
||||
<h3 id="返回值">返回值</h3>
|
||||
<p>一个新的 <a href="https://developer.mozilla.orgReference/Map" title="此页面仍未被本地化, 期待您的翻译!"><code>Map</code></a> 可迭代对象.</p>
|
||||
<h2 id="例子">例子</h2>
|
||||
<h3 id="使用_values()"><code>使用 values()</code></h3>
|
||||
<pre class="brush:js">var myMap = new Map();
|
||||
<pre><code class="language-js">var myMap = new Map();
|
||||
myMap.set("0", "foo");
|
||||
myMap.set(1, "bar");
|
||||
myMap.set({}, "baz");
|
||||
@@ -16,7 +16,7 @@ var mapIter = myMap.values();
|
||||
|
||||
console.log(mapIter.next().value); // "foo"
|
||||
console.log(mapIter.next().value); // "bar"
|
||||
console.log(mapIter.next().value); // "baz"</pre>
|
||||
console.log(mapIter.next().value); // "baz"</code></pre>
|
||||
<h2 id="规范">规范</h2>
|
||||
<table class="standard-table">
|
||||
<tbody>
|
||||
|
||||
Reference in New Issue
Block a user