diff options
author | Irvin <irvinfly@gmail.com> | 2022-02-16 02:14:18 +0800 |
---|---|---|
committer | Irvin <irvinfly@gmail.com> | 2022-02-16 02:35:54 +0800 |
commit | d44f5032d0f53256b2d5aef505d6b593fd3cd158 (patch) | |
tree | 4b585f4be9c9a2712664ad10e7acf62c83fff51f /files/zh-cn/web/javascript/reference/operators | |
parent | f45e9e070c93ebbd83d488bdd775987a4d75c201 (diff) | |
download | translated-content-d44f5032d0f53256b2d5aef505d6b593fd3cd158.tar.gz translated-content-d44f5032d0f53256b2d5aef505d6b593fd3cd158.tar.bz2 translated-content-d44f5032d0f53256b2d5aef505d6b593fd3cd158.zip |
fix yari h2m dry run errors (zh-CN)
Diffstat (limited to 'files/zh-cn/web/javascript/reference/operators')
18 files changed, 51 insertions, 147 deletions
diff --git a/files/zh-cn/web/javascript/reference/operators/await/index.html b/files/zh-cn/web/javascript/reference/operators/await/index.html index 4f0ea9b0c3..463f0e8ea1 100644 --- a/files/zh-cn/web/javascript/reference/operators/await/index.html +++ b/files/zh-cn/web/javascript/reference/operators/await/index.html @@ -95,59 +95,7 @@ f3();</pre> <h2 id="浏览器兼容性">浏览器兼容性</h2> -<div>{{CompatibilityTable}}</div> - -<div> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Chrome</th> - <th>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Edge</th> - <th>Opera</th> - <th>Safari (WebKit)</th> - </tr> - <tr> - <td>基本支持</td> - <td>{{CompatChrome(55)}}</td> - <td>{{CompatGeckoDesktop("52.0")}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatOpera(42)}}</td> - <td>{{CompatUnknown}}</td> - </tr> - </tbody> -</table> -</div> - -<div> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Android</th> - <th>Android Webview</th> - <th>Firefox Mobile (Gecko)</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - <th>Chrome for Android</th> - </tr> - <tr> - <td> 基本支持</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatGeckoMobile("52.0")}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatOpera(42)}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatChrome(55)}}</td> - </tr> - </tbody> -</table> -</div> +{{Compat}} <h2 id="查看更多">查看更多</h2> diff --git a/files/zh-cn/web/javascript/reference/operators/bitwise_and/index.html b/files/zh-cn/web/javascript/reference/operators/bitwise_and/index.html index 017d0d464c..28489e61a3 100644 --- a/files/zh-cn/web/javascript/reference/operators/bitwise_and/index.html +++ b/files/zh-cn/web/javascript/reference/operators/bitwise_and/index.html @@ -31,9 +31,9 @@ After: 10100000000000000110000000000001</pre> <table class="standard-table"> <thead> <tr> - <th class="header" scope="col">a</th> - <th class="header" scope="col">b</th> - <th class="header" scope="col">a AND b</th> + <th scope="col">a</th> + <th scope="col">b</th> + <th scope="col">a AND b</th> </tr> </thead> <tbody> diff --git a/files/zh-cn/web/javascript/reference/operators/bitwise_not/index.html b/files/zh-cn/web/javascript/reference/operators/bitwise_not/index.html index 46ffd369dd..8cd674a8cb 100644 --- a/files/zh-cn/web/javascript/reference/operators/bitwise_not/index.html +++ b/files/zh-cn/web/javascript/reference/operators/bitwise_not/index.html @@ -38,8 +38,8 @@ After: 10100000000000000110000000000001</pre> <table class="standard-table"> <thead> <tr> - <th class="header" scope="col">a</th> - <th class="header" scope="col">NOT a</th> + <th scope="col">a</th> + <th scope="col">NOT a</th> </tr> </thead> <tbody> diff --git a/files/zh-cn/web/javascript/reference/operators/bitwise_or/index.html b/files/zh-cn/web/javascript/reference/operators/bitwise_or/index.html index 2f83d5d956..5c5810d152 100644 --- a/files/zh-cn/web/javascript/reference/operators/bitwise_or/index.html +++ b/files/zh-cn/web/javascript/reference/operators/bitwise_or/index.html @@ -30,9 +30,9 @@ After: 10100000000000000110000000000001</pre> <table class="standard-table"> <thead> <tr> - <th class="header" scope="col">a</th> - <th class="header" scope="col">b</th> - <th class="header" scope="col">a OR b</th> + <th scope="col">a</th> + <th scope="col">b</th> + <th scope="col">a OR b</th> </tr> </thead> <tbody> diff --git a/files/zh-cn/web/javascript/reference/operators/bitwise_xor/index.html b/files/zh-cn/web/javascript/reference/operators/bitwise_xor/index.html index 1ec5d48f0a..9b670f4a58 100644 --- a/files/zh-cn/web/javascript/reference/operators/bitwise_xor/index.html +++ b/files/zh-cn/web/javascript/reference/operators/bitwise_xor/index.html @@ -30,9 +30,9 @@ After: 10100000000000000110000000000001</pre> <table class="standard-table"> <thead> <tr> - <th class="header" scope="col">a</th> - <th class="header" scope="col">b</th> - <th class="header" scope="col">a XOR b</th> + <th scope="col">a</th> + <th scope="col">b</th> + <th scope="col">a XOR b</th> </tr> </thead> <tbody> diff --git a/files/zh-cn/web/javascript/reference/operators/comma_operator/index.html b/files/zh-cn/web/javascript/reference/operators/comma_operator/index.html index cc7b2f83a8..1c9ca88054 100644 --- a/files/zh-cn/web/javascript/reference/operators/comma_operator/index.html +++ b/files/zh-cn/web/javascript/reference/operators/comma_operator/index.html @@ -33,7 +33,7 @@ translation_of: Web/JavaScript/Reference/Operators/Comma_Operator <p>假设 <code>a</code> 是一个二维数组,每一维度包含10个元素,则下面的代码使用逗号操作符一次递增/递减两个变量。需要注意的是,<code>var</code> 语句中的逗号<em><strong>不是</strong></em>逗号操作符,因为它不是存在于一个表达式中。尽管从实际效果来看,那个逗号同逗号运算符的表现很相似。但确切地说,它是 <code>var</code> 语句中的一个特殊符号,用于把多个变量声明结合成一个。下面的代码打印一个二维数组中斜线方向的元素:</p> -<pre class="brush:js;highlight:[1]">for (var i = 0, j = 9; i <= 9; i++, j--) +<pre class="brush:js">for (var i = 0, j = 9; i <= 9; i++, j--) document.writeln("a[" + i + "][" + j + "] = " + a[i][j]);</pre> <h3 id="处理后返回">处理后返回</h3> diff --git a/files/zh-cn/web/javascript/reference/operators/conditional_operator/index.html b/files/zh-cn/web/javascript/reference/operators/conditional_operator/index.html index cb3153c5ee..720dda3c68 100644 --- a/files/zh-cn/web/javascript/reference/operators/conditional_operator/index.html +++ b/files/zh-cn/web/javascript/reference/operators/conditional_operator/index.html @@ -52,7 +52,7 @@ console.log(greeting({name: 'Alice'})); // "Howdy, Alice" console.log(greeting(null)); // "Howdy, stranger" </pre> -<div class="blockIndicator note"> +<div class="note"> <p><strong>Note:</strong> <a href="/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining">The optional chaining operator</a> 设计用来处理这种使用场景。在本文档写成的时候 (2019.01),这个运算符还处于实验阶段并且没有实现。</p> </div> diff --git a/files/zh-cn/web/javascript/reference/operators/delete/index.html b/files/zh-cn/web/javascript/reference/operators/delete/index.html index f8b4e02e0c..f061e72ba2 100644 --- a/files/zh-cn/web/javascript/reference/operators/delete/index.html +++ b/files/zh-cn/web/javascript/reference/operators/delete/index.html @@ -131,8 +131,8 @@ console.log(delete variable2); // false console.log(delete func); // false </pre> -<div class="blockIndicator note"> -<p>下文在英文原版中已删除</p> +<div class="note"> +<p><strong>备注:</strong>下文在英文原版中已删除</p> </div> <p>任何使用var声明的变量都会被标记为不可设置的。在下面的例子中,salary是不可设置的以及不能被删除的。在非严格模式下,下面的delete操作将会返回false。</p> diff --git a/files/zh-cn/web/javascript/reference/operators/destructuring_assignment/index.html b/files/zh-cn/web/javascript/reference/operators/destructuring_assignment/index.html index 93182a3253..05cc98f3a9 100644 --- a/files/zh-cn/web/javascript/reference/operators/destructuring_assignment/index.html +++ b/files/zh-cn/web/javascript/reference/operators/destructuring_assignment/index.html @@ -188,7 +188,7 @@ console.log(q); // true </pre> <div class="note"> -<p><strong>注意</strong>:赋值语句周围的圆括号 <code>( ... )</code> 在使用对象字面量无声明解构赋值时是必须的。</p> +<p><strong>备注:</strong>赋值语句周围的圆括号 <code>( ... )</code> 在使用对象字面量无声明解构赋值时是必须的。</p> <p><code>{a, b} = {a: 1, b: 2}</code> 不是有效的独立语法,因为左边的 <code>{a, b}</code> 被认为是一个块而不是对象字面量。</p> @@ -259,7 +259,7 @@ drawES2015Chart({ });</pre> <div class="note"> -<p>在上面的 <strong><code>drawES2015Chart</code></strong> 的函数签名中,解构的左手边被分配给右手边的空对象字面值:<code>{size = 'big', cords = {x: 0, y: 0}, radius = 25} = {}</code>。你也可以在没有右侧分配的情况下编写函数。但是,如果你忽略了右边的赋值,那么函数会在被调用的时候查找至少一个被提供的参数,而在当前的形式下,你可以直接调用 <code><strong>drawES2015Chart()</strong></code> 而不提供任何参数。如果你希望能够在不提供任何参数的情况下调用该函数,则当前的设计非常有用,而另一种方法在您确保将对象传递给函数时非常有用。</p> +<p><strong>备注:</strong>在上面的 <strong><code>drawES2015Chart</code></strong> 的函数签名中,解构的左手边被分配给右手边的空对象字面值:<code>{size = 'big', cords = {x: 0, y: 0}, radius = 25} = {}</code>。你也可以在没有右侧分配的情况下编写函数。但是,如果你忽略了右边的赋值,那么函数会在被调用的时候查找至少一个被提供的参数,而在当前的形式下,你可以直接调用 <code><strong>drawES2015Chart()</strong></code> 而不提供任何参数。如果你希望能够在不提供任何参数的情况下调用该函数,则当前的设计非常有用,而另一种方法在您确保将对象传递给函数时非常有用。</p> </div> <h3 id="解构嵌套对象和数组">解构嵌套对象和数组</h3> diff --git a/files/zh-cn/web/javascript/reference/operators/function/index.html b/files/zh-cn/web/javascript/reference/operators/function/index.html index c3c9bd85ea..5a69175075 100644 --- a/files/zh-cn/web/javascript/reference/operators/function/index.html +++ b/files/zh-cn/web/javascript/reference/operators/function/index.html @@ -120,55 +120,7 @@ console.log(bar === baz); // false (errors because baz == undefined)</code> <h2 id="浏览器兼容性">浏览器兼容性</h2> -<p>{{ CompatibilityTable() }}</p> - -<div> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Chrome</th> - <th>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{ CompatVersionUnknown() }}</td> - <td>{{ CompatVersionUnknown() }}</td> - <td>{{ CompatVersionUnknown() }}</td> - <td>{{ CompatVersionUnknown() }}</td> - <td>{{ CompatVersionUnknown() }}</td> - </tr> - </tbody> -</table> -</div> - -<div> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Android</th> - <th>Chrome for Android</th> - <th>Firefox Mobile (Gecko)</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{ CompatVersionUnknown() }}</td> - <td>{{ CompatVersionUnknown() }}</td> - <td>{{ CompatVersionUnknown() }}</td> - <td>{{ CompatVersionUnknown() }}</td> - <td>{{ CompatVersionUnknown() }}</td> - <td>{{ CompatVersionUnknown() }}</td> - </tr> - </tbody> -</table> -</div> +{{Compat}} <h2 id="See_also">相关链接</h2> diff --git a/files/zh-cn/web/javascript/reference/operators/index.html b/files/zh-cn/web/javascript/reference/operators/index.html index 810ccb74cd..82ff728c29 100644 --- a/files/zh-cn/web/javascript/reference/operators/index.html +++ b/files/zh-cn/web/javascript/reference/operators/index.html @@ -135,7 +135,9 @@ translation_of: Web/JavaScript/Reference/Operators <dd>大于等于运算符。 </dd> </dl> -<div class="note"><strong>注意: =></strong> 不是运算符,而是{{jsxref("Functions/Arrow_functions", "箭头函数")}}的表示符。</div> +<div class="note"> +<p><strong>备注:</strong> 不是运算符,而是{{jsxref("Functions/Arrow_functions", "箭头函数")}}的表示符。</p> +</div> <h3 id="相等运算符">相等运算符</h3> @@ -241,11 +243,11 @@ translation_of: Web/JavaScript/Reference/Operators <p>解构赋值允许你分配数组或者对象变量的属性通过使用规定的语法,其看起来和数组和对象字面量很相似。</p> </dd> <dt> - <h3 id="逗号操作符">逗号操作符 {{jsxref("Operators/Comma_Operator", ",")}}</h3> + 逗号操作符 {{jsxref("Operators/Comma_Operator", ",")}} </dt> <dd>逗号操作符允许在一个判断状态中有多个表达式去进行运算并且最后返回最后一个表达式的值。</dd> <dt> - <h3 id="非标准化特性">非标准化特性 {{JSxRef("Operators/Expression_closures", "Expression closures", "", 1)}} {{non-standard_inline}}{{obsolete_inline(60)}}</h3> + 非标准化特性 {{JSxRef("Operators/Expression_closures", "Expression closures", "", 1)}} {{non-standard_inline}}{{obsolete_inline(60)}} </dt> <dd>闭包表达式语法是一个缩写简单的函数。</dd> <dt>{{JSxRef("Operators/Legacy_generator_function", "Legacy generator function", "", 1)}} {{non-standard_inline}}{{obsolete_inline(58)}}</dt> diff --git a/files/zh-cn/web/javascript/reference/operators/instanceof/index.html b/files/zh-cn/web/javascript/reference/operators/instanceof/index.html index f6f1f188f8..bb93a7028e 100644 --- a/files/zh-cn/web/javascript/reference/operators/instanceof/index.html +++ b/files/zh-cn/web/javascript/reference/operators/instanceof/index.html @@ -73,8 +73,12 @@ o3 instanceof C; // true 因为 C.prototype 现在在 o3 的原型链上 <p>比如检测一个 <code>Nodes</code> 在另一个窗口中是不是 <code>SVGElement</code>,你可以使用<code>myNode instanceof myNode.ownerDocument.defaultView.SVGElement</code></p> -<div class="note"><strong>Mozilla开发者注意:</strong><br> -在代码中使用 XPCOM <code>instanceof </code>有特殊影响: 如果查询接口成功执行后,<code>obj instanceof </code><em><code>xpcomInterface</code></em> (e.g. <code>Components.interfaces.nsIFile</code>) 调用<code>obj.QueryInterface(<em>xpcomInterface</em>)</code> 并且返回 <code>true</code> 。这种调用的副作用是在一次成功的 <code>instanceof</code> 测试后,你可以在 <code>obj</code> 上使用<code>xpcomInterface</code> 的属性。这与标准的 <code>JavaScript</code> 全局变量不同,即使 <code>obj</code> 来自不同的作用域,<code>obj instanceof xpcomInterface</code> 也可以按预期产生作用。</div> +<div class="note"> +<p> + <strong>备注:</strong> + 在代码中使用 XPCOM <code>instanceof </code>有特殊影响: 如果查询接口成功执行后,<code>obj instanceof </code><em><code>xpcomInterface</code></em> (e.g. <code>Components.interfaces.nsIFile</code>) 调用<code>obj.QueryInterface(<em>xpcomInterface</em>)</code> 并且返回 <code>true</code> 。这种调用的副作用是在一次成功的 <code>instanceof</code> 测试后,你可以在 <code>obj</code> 上使用<code>xpcomInterface</code> 的属性。这与标准的 <code>JavaScript</code> 全局变量不同,即使 <code>obj</code> 来自不同的作用域,<code>obj instanceof xpcomInterface</code> 也可以按预期产生作用。 +</p> +</div> <h2 id="Examples">示例</h2> diff --git a/files/zh-cn/web/javascript/reference/operators/logical_or/index.html b/files/zh-cn/web/javascript/reference/operators/logical_or/index.html index d159e76866..69f521ca62 100644 --- a/files/zh-cn/web/javascript/reference/operators/logical_or/index.html +++ b/files/zh-cn/web/javascript/reference/operators/logical_or/index.html @@ -73,8 +73,8 @@ o9 = false || '' // f || f returns "" o10 = false || varObject // f || object returns varObject </pre> -<div class="blockIndicator note"> -<p><strong>Note:</strong> If you use this operator to provide a default value to some variable, be aware that any <em>falsy</em> value will not be used. If you only need to filter out {{jsxref("null")}} or {{jsxref("undefined")}}, consider using <a href="/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing_operator">the nullish coalescing operator</a>.</p> +<div class="note"> +<p><strong>备注:</strong> If you use this operator to provide a default value to some variable, be aware that any <em>falsy</em> value will not be used. If you only need to filter out {{jsxref("null")}} or {{jsxref("undefined")}}, consider using <a href="/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing_operator">the nullish coalescing operator</a>.</p> </div> <h3 id="Conversion_rules_for_booleans">Conversion rules for booleans</h3> diff --git a/files/zh-cn/web/javascript/reference/operators/new/index.html b/files/zh-cn/web/javascript/reference/operators/new/index.html index e44beb9763..4959409c31 100644 --- a/files/zh-cn/web/javascript/reference/operators/new/index.html +++ b/files/zh-cn/web/javascript/reference/operators/new/index.html @@ -83,7 +83,7 @@ console.log(car2.color) // original color </pre> <div class="note"> -<p>如果你没有使用 <code>new</code> 运算符, <strong>构造函数会像其他的常规函数一样被调用,</strong> 并<em>不会创建一个对象<strong>。</strong></em>在这种情况下, <code>this</code> 的指向也是不一样的。</p> +<p><strong>备注:</strong>如果你没有使用 <code>new</code> 运算符, <strong>构造函数会像其他的常规函数一样被调用,</strong> 并<em>不会创建一个对象<strong>。</strong></em>在这种情况下, <code>this</code> 的指向也是不一样的。</p> </div> <h2 id="示例">示例</h2> diff --git a/files/zh-cn/web/javascript/reference/operators/optional_chaining/index.html b/files/zh-cn/web/javascript/reference/operators/optional_chaining/index.html index e765e6d66b..9c3f743c8a 100644 --- a/files/zh-cn/web/javascript/reference/operators/optional_chaining/index.html +++ b/files/zh-cn/web/javascript/reference/operators/optional_chaining/index.html @@ -61,12 +61,12 @@ let nestedProp = ((temp === null || temp === undefined) ? undefined : temp.secon <pre class="brush: js">let result = someInterface.customMethod?.();</pre> -<div class="blockIndicator note"> -<p><strong>注意:</strong> 如果存在一个属性名且不是函数, 使用 <code>?.</code> 仍然会产生一个 {{JSxRef("TypeError")}} 异常 (<code>x.y</code><code> is not a function</code>).</p> +<div class="note"> +<p><strong>备注:</strong>如果存在一个属性名且不是函数, 使用 <code>?.</code> 仍然会产生一个 {{JSxRef("TypeError")}} 异常 (<code>x.y</code><code> is not a function</code>).</p> </div> -<div class="blockIndicator note"> -<p><strong>注意:</strong> 如果 <code>someInterface</code> 自身是 <code>null</code> 或者 <code>undefined</code> ,异常 {{JSxRef("TypeError")}} 仍会被抛出 <code>someInterface is null</code> 如果你希望允许 <code>someInterface</code> 也为 <code>null</code> 或者 <code>undefined</code> ,那么你需要像这样写 <code>someInterface?.customMethod?.()</code></p> +<div class="note"> +<p><strong>备注:</strong>如果 <code>someInterface</code> 自身是 <code>null</code> 或者 <code>undefined</code> ,异常 {{JSxRef("TypeError")}} 仍会被抛出 <code>someInterface is null</code> 如果你希望允许 <code>someInterface</code> 也为 <code>null</code> 或者 <code>undefined</code> ,那么你需要像这样写 <code>someInterface?.customMethod?.()</code></p> </div> <h4 id="处理可选的回调函数或者事件处理器">处理可选的回调函数或者事件处理器</h4> diff --git a/files/zh-cn/web/javascript/reference/operators/property_accessors/index.html b/files/zh-cn/web/javascript/reference/operators/property_accessors/index.html index c7c482256d..6d139479f9 100644 --- a/files/zh-cn/web/javascript/reference/operators/property_accessors/index.html +++ b/files/zh-cn/web/javascript/reference/operators/property_accessors/index.html @@ -23,7 +23,7 @@ object['property'] <h2 id="描述">描述</h2> -<p class="syntaxbox">我们可以将对象看做是一个<em>关联数组(</em>或者:<em>映射</em>、<em>字典</em>、<em>哈希表</em>、<em>查询表</em>)。这个数组中的键就是这个对象中属性的名称。通常,当我们提及一个对象的属性时,会对属性与方法之间做个对比。然而,属性与方法之间的区别并不大。一个方法就是一个可以被调用的属性而已,例如一个指向函数 <a href="/zh-CN/docs/Glossary/Function">Function</a> 实例的引用可以作为对象属性的值。</p> +<p>我们可以将对象看做是一个<em>关联数组(</em>或者:<em>映射</em>、<em>字典</em>、<em>哈希表</em>、<em>查询表</em>)。这个数组中的键就是这个对象中属性的名称。通常,当我们提及一个对象的属性时,会对属性与方法之间做个对比。然而,属性与方法之间的区别并不大。一个方法就是一个可以被调用的属性而已,例如一个指向函数 <a href="/zh-CN/docs/Glossary/Function">Function</a> 实例的引用可以作为对象属性的值。</p> <p>访问对象属性有两种方式:点号表示法和方括号表示法。</p> diff --git a/files/zh-cn/web/javascript/reference/operators/this/index.html b/files/zh-cn/web/javascript/reference/operators/this/index.html index 86616407d0..8e79b0d0d5 100644 --- a/files/zh-cn/web/javascript/reference/operators/this/index.html +++ b/files/zh-cn/web/javascript/reference/operators/this/index.html @@ -42,8 +42,8 @@ this.b = "MDN"; console.log(window.b) // "MDN" console.log(b) // "MDN"</pre> -<div class="blockIndicator note"> -<p><strong>Note:</strong> 你可以使用 {{jsxref("globalThis")}} 获取全局对象,无论你的代码是否在当前上下文运行。</p> +<div class="note"> +<p><strong>备注:</strong>你可以使用 {{jsxref("globalThis")}} 获取全局对象,无论你的代码是否在当前上下文运行。</p> </div> <h3 id="函数上下文">函数上下文</h3> @@ -72,7 +72,9 @@ f1() === globalThis; f2() === undefined; // true </pre> -<div class="note">在第二个例子中,<code>this</code> 应是 <a href="/zh-CN/docs/Glossary/undefined">undefined</a>,因为 <code>f2</code> 是被直接调用的,而不是作为对象的属性或方法调用的(如 <code>window.f2()</code>)。有一些浏览器最初在支持<a href="/zh-CN/docs/Web/JavaScript/Reference/Strict_mode">严格模式</a>时没有正确实现这个功能,于是它们错误地返回了<code>window</code>对象。</div> +<div class="note"> + <p><strong>备注:</strong>在第二个例子中,<code>this</code> 应是 <a href="/zh-CN/docs/Glossary/undefined">undefined</a>,因为 <code>f2</code> 是被直接调用的,而不是作为对象的属性或方法调用的(如 <code>window.f2()</code>)。有一些浏览器最初在支持<a href="/zh-CN/docs/Web/JavaScript/Reference/Strict_mode">严格模式</a>时没有正确实现这个功能,于是它们错误地返回了<code>window</code>对象。</p> +</div> <p>如果要想把 <code>this</code> 的值从一个环境传到另一个,就要用 <code><a href="/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Function/call">call</a></code> 或者<code><a href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Function/apply">apply</a></code> 方法,如下方的示例所示。</p> @@ -94,8 +96,8 @@ f2() === undefined; // true new Example(); // ['constructor', 'first', 'second']</pre> -<div class="blockIndicator note"> -<p><strong>注意:</strong>静态方法不是 this 的属性,它们只是类自身的属性。</p> +<div class="note"> +<p><strong>备注:</strong>静态方法不是 this 的属性,它们只是类自身的属性。</p> </div> <h3 id="派生类">派生类</h3> @@ -104,7 +106,7 @@ new Example(); // ['constructor', 'first', 'second']</pre> <pre>this = new Base();</pre> -<div class="blockIndicator warning"> +<div class="warning"> <p><strong>警告:</strong>在调用 <code>super()</code> 之前引用 <code>this</code> 会抛出错误。</p> </div> @@ -199,7 +201,7 @@ var foo = (() => this); console.log(foo() === globalObject); // true</pre> <div class="note"> -<p>注意:如果将<code>this</code>传递给<code>call</code>、<code>bind</code>、或者<code>apply</code>来调用箭头函数,它将被忽略。不过你仍然可以为调用添加参数,不过第一个参数(<code>thisArg</code>)应该设置为<code>null</code>。</p> +<p><strong>备注:</strong>如果将<code>this</code>传递给<code>call</code>、<code>bind</code>、或者<code>apply</code>来调用箭头函数,它将被忽略。不过你仍然可以为调用添加参数,不过第一个参数(<code>thisArg</code>)应该设置为<code>null</code>。</p> </div> <pre class="brush: js">// 接着上面的代码 @@ -328,7 +330,7 @@ console.log(o.average, o.sum); // logs 2, 6 <p>当一个函数用作构造函数时(使用<a href="/zh-CN/docs/Web/JavaScript/Reference/Operators/new">new</a>关键字),它的<code>this</code>被绑定到正在构造的新对象。</p> <div class="note"> -<p>虽然构造函数返回的默认值是 <code>this</code> 所指的那个对象,但它仍可以手动返回其他的对象(如果返回值不是一个对象,则返回 <code>this</code> 对象)。</p> +<p><strong>备注:</strong>虽然构造函数返回的默认值是 <code>this</code> 所指的那个对象,但它仍可以手动返回其他的对象(如果返回值不是一个对象,则返回 <code>this</code> 对象)。</p> </div> <pre class="brush: js">/* @@ -443,8 +445,8 @@ bird.sayHi(); // Hello from Tweety bird.sayBye = car.sayBye; bird.sayBye(); // Bye from Ferrari</pre> -<div class="blockIndicator note"> -<p><strong>注意:</strong>类内部总是严格模式。调用一个 <code>this</code> 值为 undefined 的方法会抛出错误。</p> +<div class="note"> +<p><strong>备注:</strong>类内部总是严格模式。调用一个 <code>this</code> 值为 undefined 的方法会抛出错误。</p> </div> <h2 id="规范">规范</h2> diff --git a/files/zh-cn/web/javascript/reference/operators/typeof/index.html b/files/zh-cn/web/javascript/reference/operators/typeof/index.html index ae77ab6261..1a149d5ed6 100644 --- a/files/zh-cn/web/javascript/reference/operators/typeof/index.html +++ b/files/zh-cn/web/javascript/reference/operators/typeof/index.html @@ -27,9 +27,7 @@ typeof(operand)</em> <p><strong><code>operand</code></strong></p> -<dl> - <dd>一个表示对象或{{Glossary("Primitive", "原始值")}}的表达式,其类型将被返回。</dd> -</dl> +<p>一个表示对象或{{Glossary("Primitive", "原始值")}}的表达式,其类型将被返回。</p> <h2 id="描述">描述</h2> @@ -268,8 +266,6 @@ class newClass{};</pre> <pre class="brush: js">typeof alert === 'object'</pre> </div> -<div class="brush:js language-js line-number"></div> - <h2 id="See_also">相关链接</h2> <ul> |