diff options
author | Irvin <irvinfly@gmail.com> | 2022-02-16 02:02:49 +0800 |
---|---|---|
committer | Irvin <irvinfly@gmail.com> | 2022-02-16 02:35:54 +0800 |
commit | 01b0e12ba27b5069248fd09235e9a7143915ee30 (patch) | |
tree | 0e9edf538dc3fa3331e1dbb79239b58186765f86 /files/zh-cn/web/javascript/reference/global_objects/symbol | |
parent | 6ca84f1794af830ada9736d7289ce29aabb04ca3 (diff) | |
download | translated-content-01b0e12ba27b5069248fd09235e9a7143915ee30.tar.gz translated-content-01b0e12ba27b5069248fd09235e9a7143915ee30.tar.bz2 translated-content-01b0e12ba27b5069248fd09235e9a7143915ee30.zip |
remove `notranslate` class in zh-CN
Diffstat (limited to 'files/zh-cn/web/javascript/reference/global_objects/symbol')
5 files changed, 15 insertions, 15 deletions
diff --git a/files/zh-cn/web/javascript/reference/global_objects/symbol/hasinstance/index.html b/files/zh-cn/web/javascript/reference/global_objects/symbol/hasinstance/index.html index 2381f6654f..c4d2d0753a 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/symbol/hasinstance/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/symbol/hasinstance/index.html @@ -19,7 +19,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Symbol/hasInstance <p>你可实现一个自定义的<code>instanceof</code> 行为,例如:</p> -<pre class="brush: js notranslate">class MyArray { +<pre class="brush: js">class MyArray { static [Symbol.hasInstance](instance) { return Array.isArray(instance); } diff --git a/files/zh-cn/web/javascript/reference/global_objects/symbol/index.html b/files/zh-cn/web/javascript/reference/global_objects/symbol/index.html index 5e23754b25..9473363551 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/symbol/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/symbol/index.html @@ -19,7 +19,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Symbol <h2 id="Syntax" name="Syntax">语法</h2> -<pre class="syntaxbox notranslate"><code>Symbol(<em>[description]</em>)</code></pre> +<pre class="syntaxbox"><code>Symbol(<em>[description]</em>)</code></pre> <h3 id="Parameters" name="Parameters">参数</h3> @@ -32,24 +32,24 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Symbol <p>直接使用<code>Symbol()</code>创建新的symbol类型,并用一个可选的字符串作为其描述。</p> -<pre class="brush: js notranslate">var sym1 = Symbol(); +<pre class="brush: js">var sym1 = Symbol(); var sym2 = Symbol('foo'); var sym3 = Symbol('foo'); </pre> <p>上面的代码创建了三个新的symbol类型。 注意,<code>Symbol("foo")</code> 不会强制将字符串 “foo” 转换成symbol类型。它每次都会创建一个新的 symbol类型:</p> -<pre class="brush: js notranslate">Symbol("foo") === Symbol("foo"); // false</pre> +<pre class="brush: js">Symbol("foo") === Symbol("foo"); // false</pre> <p>下面带有 {{jsxref("Operators/new", "new")}} 运算符的语法将抛出 {{jsxref("TypeError")}} 错误:</p> -<pre class="brush: js notranslate">var sym = new Symbol(); // TypeError</pre> +<pre class="brush: js">var sym = new Symbol(); // TypeError</pre> <p>这会阻止创建一个显式的 Symbol 包装器对象而不是一个 Symbol 值。围绕原始数据类型创建一个显式包装器对象从 ECMAScript 6 开始不再被支持。 然而,现有的原始包装器对象,如 <code style="font-style: normal;">new Boolean</code>、<code style="font-style: normal;">new String</code>以及<code>new Number</code>,因为遗留原因仍可被创建。</p> <p>如果你真的想创建一个 <u>Symbol 包装器对象 </u>(<code>Symbol wrapper object</code>),你可以使用 <code>Object()</code> 函数:</p> -<pre class="brush: js notranslate">var sym = Symbol("foo"); +<pre class="brush: js">var sym = Symbol("foo"); typeof sym; // "symbol" var symObj = Object(sym); typeof symObj; // "object"</pre> @@ -150,7 +150,7 @@ typeof symObj; // "object"</pre> <p> {{jsxref("Operators/typeof", "typeof")}}运算符能帮助你识别 symbol 类型</p> -<pre class="brush: js notranslate"><code class="language-js">typeof Symbol() === 'symbol' +<pre class="brush: js"><code class="language-js">typeof Symbol() === 'symbol' typeof Symbol('foo') === 'symbol' typeof Symbol.iterator === 'symbol'</code> </pre> @@ -170,7 +170,7 @@ typeof Symbol.iterator === 'symbol'</code> <p>Symbols 在 <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in"><code>for...in</code></a> 迭代中不可枚举。另外,{{jsxref("Object.getOwnPropertyNames()")}} 不会返回 symbol 对象的属性,但是你能使用 {{jsxref("Object.getOwnPropertySymbols()")}} 得到它们。</p> -<pre class="brush: js line-numbers language-js notranslate"><code class="language-js">var obj = {}; +<pre class="brush: js line-numbers language-js"><code class="language-js">var obj = {}; obj[Symbol("a")] = "a"; obj[Symbol.for("b")] = "b"; @@ -185,7 +185,7 @@ for (var i in obj) { <p>当使用 JSON.stringify() 时,以 symbol 值作为键的属性会被完全忽略:</p> -<pre class="brush: js notranslate"><code class="language-js">JSON.stringify({[Symbol("foo")]: "foo"}); +<pre class="brush: js"><code class="language-js">JSON.stringify({[Symbol("foo")]: "foo"}); // '{}'</code></pre> <p>更多细节,请看 {{jsxref("JSON.stringify()")}}。</p> @@ -194,7 +194,7 @@ for (var i in obj) { <p>当一个 Symbol 包装器对象作为一个属性的键时,这个对象将被强制转换为它包装过的 symbol 值:</p> -<pre class="brush: js notranslate"><code class="language-js">var sym = Symbol("foo"); +<pre class="brush: js"><code class="language-js">var sym = Symbol("foo"); var obj = {[sym]: 1}; obj[sym]; // 1 obj[Object(sym)]; // still 1</code></pre> diff --git a/files/zh-cn/web/javascript/reference/global_objects/symbol/keyfor/index.html b/files/zh-cn/web/javascript/reference/global_objects/symbol/keyfor/index.html index 150ae66f02..c38fa9307b 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/symbol/keyfor/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/symbol/keyfor/index.html @@ -11,7 +11,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Symbol/keyFor <h2 id="Syntax" name="Syntax">语法</h2> -<pre class="syntaxbox notranslate"><var>Symbol.keyFor(sym)</var>;</pre> +<pre class="syntaxbox"><var>Symbol.keyFor(sym)</var>;</pre> <h3 id="参数">参数</h3> @@ -28,7 +28,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Symbol/keyFor <h2 id="示例">示例</h2> -<pre class="brush: js notranslate">// 创建一个全局 Symbol +<pre class="brush: js">// 创建一个全局 Symbol var globalSym = Symbol.for("foo"); Symbol.keyFor(globalSym); // "foo" diff --git a/files/zh-cn/web/javascript/reference/global_objects/symbol/search/index.html b/files/zh-cn/web/javascript/reference/global_objects/symbol/search/index.html index c1efdd302e..f3d595a2fb 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/symbol/search/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/symbol/search/index.html @@ -17,7 +17,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Symbol/search <h3 id="自定义字符串搜索">自定义字符串搜索</h3> -<pre class="notranslate">class caseInsensitiveSearch { +<pre>class caseInsensitiveSearch { constructor(value) { this.value = value.toLowerCase(); } diff --git a/files/zh-cn/web/javascript/reference/global_objects/symbol/split/index.html b/files/zh-cn/web/javascript/reference/global_objects/symbol/split/index.html index 53b98d57cd..221254014b 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/symbol/split/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/symbol/split/index.html @@ -19,11 +19,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Symbol/split <p>[Symbol.split]指向‘aba’.split(/a/)</p> -<pre class="brush: js notranslate">/a/[Symbol.split]('aba',3)</pre> +<pre class="brush: js">/a/[Symbol.split]('aba',3)</pre> <p>"dayinlove".split(exp)调用[Symbol.split](str)处理,并把实参"dayinlove"传给形参str</p> -<pre class="brush: js notranslate">var exp = { +<pre class="brush: js">var exp = { pat:'in', [Symbol.split](str) { return str.split(this.pat); |