aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/global_objects
diff options
context:
space:
mode:
authort7yang <t7yang@gmail.com>2022-01-10 08:38:07 +0800
committerIrvin <irvinfly@gmail.com>2022-02-16 02:35:54 +0800
commit563ca0a35e98678e2b7d5f154f31f496851e8d60 (patch)
tree7c99e7e037128217eca2080df671a742076c615b /files/zh-cn/web/javascript/reference/global_objects
parentd7b2995cabe8d85a1827aa18bc270bdf739f3d13 (diff)
downloadtranslated-content-563ca0a35e98678e2b7d5f154f31f496851e8d60.tar.gz
translated-content-563ca0a35e98678e2b7d5f154f31f496851e8d60.tar.bz2
translated-content-563ca0a35e98678e2b7d5f154f31f496851e8d60.zip
remove code tag inside pre tag for zh-CN
Diffstat (limited to 'files/zh-cn/web/javascript/reference/global_objects')
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/array/flat/index.html12
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/array/length/index.html8
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/date/getdate/index.html6
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/date/getday/index.html6
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/date/getfullyear/index.html2
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/date/gethours/index.html4
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/date/getmilliseconds/index.html4
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/date/getminutes/index.html6
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/date/getseconds/index.html6
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/date/gettimezoneoffset/index.html2
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/date/parse/index.html16
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/date/setfullyear/index.html6
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/infinity/index.html4
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/isfinite/index.html4
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/isnan/index.html4
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/math/pi/index.html4
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/math/random/index.html10
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/math/sign/index.html4
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/object/getownpropertydescriptors/index.html4
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/object/valueof/index.html4
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/parsefloat/index.html8
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/set/has/index.html4
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/string/match/index.html16
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/string/padstart/index.html8
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/string/repeat/index.html4
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/string/tolowercase/index.html2
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/symbol/index.html16
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/undefined/index.html4
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/webassembly/index.html4
29 files changed, 90 insertions, 92 deletions
diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/flat/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/flat/index.html
index f6a9420e21..4f06aff1fc 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/array/flat/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/array/flat/index.html
@@ -78,16 +78,14 @@ const flattened = arr =&gt; [].concat(...arr);</code></pre>
<h3 class="brush: js" id="reduce_concat_isArray_recursivity">reduce + concat + isArray + recursivity</h3>
-<pre class="brush: js"><code>// 使用 reduce、concat 和递归展开无限多层嵌套的数组
-var arr1 = [1,2,3,[1,2,3,4, [2,3,4]]];
-</code>
-<code class="language-js">function flatDeep(arr, d = 1) {
+<pre class="brush: js">// 使用 reduce、concat 和递归展开无限多层嵌套的数组
+ var arr1 = [1,2,3,[1,2,3,4, [2,3,4]]];
+function flatDeep(arr, d = 1) {
return d &gt; 0 ? arr.reduce((acc, val) =&gt; acc.concat(Array.isArray(val) ? flatDeep(val, d - 1) : val), [])
: arr.slice();
-};</code>
-<code>
+};
flatDeep(arr1, Infinity);
-// [1, 2, 3, 1, 2, 3, 4, 2, 3, 4]</code></pre>
+// [1, 2, 3, 1, 2, 3, 4, 2, 3, 4]</pre>
<h3 id="forEachisArraypushrecursivity">forEach+isArray+push+recursivity</h3>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/length/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/length/index.html
index 8f17e9af1f..de5862921d 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/array/length/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/array/length/index.html
@@ -82,25 +82,25 @@ function printEntries(arr) {
<p>下面的例子中,通过数组下标遍历数组元素,并把每个元素的值修改为原值的2倍。</p>
-<pre class="brush: js line-numbers language-js"><code class="language-js">var numbers = [1, 2, 3, 4, 5];
+<pre class="brush: js line-numbers language-js">var numbers = [1, 2, 3, 4, 5];
var length = numbers.length;
for (var i = 0; i &lt; length; i++) {
numbers[i] *= 2;
}
-// 遍历后的结果 [2, 4, 6, 8, 10]</code></pre>
+// 遍历后的结果 [2, 4, 6, 8, 10]</pre>
<h3 id="Example:_Shortening_an_array" name="Example:_Shortening_an_array">截断数组</h3>
<p>下面的例子中,如果数组长度大于 3,则把该数组的长度截断为 3 。</p>
-<pre class="brush: js line-numbers language-js"><code class="language-js">var numbers = [1, 2, 3, 4, 5];
+<pre class="brush: js line-numbers language-js">var numbers = [1, 2, 3, 4, 5];
if (numbers.length &gt; 3) {
numbers.length = 3;
}
console.log(numbers); // [1, 2, 3]
-console.log(numbers.length); // 3</code></pre>
+console.log(numbers.length); // 3</pre>
<h2 id="规范">规范</h2>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/getdate/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/getdate/index.html
index 5f7d438415..57f12998f6 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/date/getdate/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/date/getdate/index.html
@@ -13,7 +13,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getDate
<h2 id="Syntax" name="Syntax">语法</h2>
-<pre class="syntaxbox language-html"><code class="language-html">dateObj.getDate()</code></pre>
+<pre class="syntaxbox language-html">dateObj.getDate()</pre>
<h2 id="Parameters" name="Parameters">参数</h2>
@@ -29,10 +29,10 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getDate
<p>下面第二条语句将值25赋给 day 变量,该值基于日期对象 <code>Xmax95</code>的值。</p>
-<pre class="brush:js language-js"><code class="language-js">var Xmas95 = new Date("December 25, 1995 23:15:00");
+<pre class="brush:js language-js">var Xmas95 = new Date("December 25, 1995 23:15:00");
var day = Xmas95.getDate();
-alert(day); // 25</code></pre>
+alert(day); // 25</pre>
<h2 id="规范">规范</h2>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/getday/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/getday/index.html
index b2ee4a80cd..584180a8fb 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/date/getday/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/date/getday/index.html
@@ -13,7 +13,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getDay
<h2 id="Syntax" name="Syntax">语法</h2>
-<pre class="syntaxbox language-html"><code class="language-html"><em>dateObj</em>.getDay()</code>
+<pre class="syntaxbox language-html"><em>dateObj</em>.getDay()
</pre>
<h3 id="Description" name="Description">返回值</h3>
@@ -26,10 +26,10 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getDay
<p>下面第二条语句,基于{{jsxref("Date")}}对象 <code>Xmas95</code> 的值,把 1 赋值给 <code>weekday</code>。也就是说1995年12月25日是星期一。</p>
-<pre class="brush:js language-js"><code class="language-js">var Xmas95 = new Date("December 25, 1995 23:15:30");
+<pre class="brush:js language-js">var Xmas95 = new Date("December 25, 1995 23:15:30");
var weekday = Xmas95.getDay();
-console.log(weekday); // 1</code></pre>
+console.log(weekday); // 1</pre>
<div class="blockIndicator note">
<p dir="ltr">注意:如果需要,可以使用{{jsxref("DateTimeFormat", "Intl.DateTimeFormat")}}与一个额外的<code>options</code> 参数,从而返回这天的全称(如<code>"Monday"</code>).使用此方法,结果会更加国际化:</p>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/getfullyear/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/getfullyear/index.html
index 6b8638c52d..c29a10aa45 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/date/getfullyear/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/date/getfullyear/index.html
@@ -21,7 +21,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getFullYear
<h2 id="Syntax" name="Syntax">语法</h2>
-<pre><code class="language-html">dateObj.getFullYear()</code>
+<pre class="brush: html">dateObj.getFullYear()
</pre>
<h3 id="Description" name="Description">返回值</h3>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/gethours/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/gethours/index.html
index fda9396354..62d35dd713 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/date/gethours/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/date/gethours/index.html
@@ -29,10 +29,10 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getHours
<p>下面第二条语句,基于日期对象 <code>Xmas95 </code>的值,把 23 赋值给了变量 <code>hours。</code></p>
-<pre class="brush:js language-js"><code class="language-js">var Xmas95 = new Date("December 25, 1995 23:15:00");
+<pre class="brush:js language-js">var Xmas95 = new Date("December 25, 1995 23:15:00");
var hours = Xmas95.getHours();
-alert(hours); // 23</code></pre>
+alert(hours); // 23</pre>
<h2 id="规范">规范</h2>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/getmilliseconds/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/getmilliseconds/index.html
index c5dd09e3d9..2cbc0b9d30 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/date/getmilliseconds/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/date/getmilliseconds/index.html
@@ -29,9 +29,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getMilliseconds
<p>下例中,将当前时间的毫秒数赋值给变量 <code>ms</code>。</p>
-<pre class="brush: js language-js"><code class="language-js">var ms;
+<pre class="brush: js language-js">var ms;
Today = new Date();
-ms = Today.getMilliseconds();</code></pre>
+ms = Today.getMilliseconds();</pre>
<h2 id="规范">规范</h2>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/getminutes/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/getminutes/index.html
index 8322a9e813..a27f4c265d 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/date/getminutes/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/date/getminutes/index.html
@@ -11,7 +11,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getMinutes
<h2 id="Syntax" name="Syntax">语法</h2>
-<pre class="syntaxbox language-html"><code class="language-html">dateObj.getMinutes()</code></pre>
+<pre class="syntaxbox language-html">dateObj.getMinutes()</pre>
<h3 id="Parameters" name="Parameters">参数</h3>
@@ -27,8 +27,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getMinutes
<p>下例中,第二行语句运行过后,变量 <code>minutes </code>的值为15,也就是说 <code>Xmas95 </code>这个日期对象的值为某时15分某秒。</p>
-<pre class="brush:js language-js"><code class="language-js">var Xmas95 = new Date("December 25, 1995 23:15:00");
-var minutes = Xmas95.getMinutes();</code></pre>
+<pre class="brush:js language-js">var Xmas95 = new Date("December 25, 1995 23:15:00");
+var minutes = Xmas95.getMinutes();</pre>
<p dir="ltr"><strong>规范</strong></p>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/getseconds/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/getseconds/index.html
index ded6203208..1cb80b2ea8 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/date/getseconds/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/date/getseconds/index.html
@@ -13,7 +13,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getSeconds
<h2 id="Syntax" name="Syntax">语法</h2>
-<pre class="syntaxbox language-html"><code class="language-html">dateObj.getSeconds()</code></pre>
+<pre class="syntaxbox language-html">dateObj.getSeconds()</pre>
<h3 id="Parameters" name="Parameters">参数</h3>
@@ -29,8 +29,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getSeconds
<p>下面第二条语句,基于日期对象 <code>Xmas95</code> 的值,把 30 赋值给变量 <code>secs</code>。</p>
-<pre class="brush:js language-js"><code class="language-js">var Xmas95 = new Date("December 25, 1995 23:15:30");
-var secs = Xmas95.getSeconds();</code></pre>
+<pre class="brush:js language-js">var Xmas95 = new Date("December 25, 1995 23:15:30");
+var secs = Xmas95.getSeconds();</pre>
<div class="line-number"> </div>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/gettimezoneoffset/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/gettimezoneoffset/index.html
index 7ee056a7df..90b7d1a962 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/date/gettimezoneoffset/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/date/gettimezoneoffset/index.html
@@ -13,7 +13,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset
<h2 id="Syntax" name="Syntax">语法</h2>
-<pre class="syntaxbox language-html"><code class="language-html">dateObj.getTimezoneOffset()</code></pre>
+<pre class="syntaxbox language-html">dateObj.getTimezoneOffset()</pre>
<h3 id="Parameters" name="Parameters">参数</h3>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/parse/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/parse/index.html
index 68a8d136e7..5b0a6cf01d 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/date/parse/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/date/parse/index.html
@@ -70,26 +70,26 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/parse
<p>但是, 在如 ECMA-262 规范中定义的情况,如果因为无效值而导致日期字符串不能被识别为 ISO 格式时,根据浏览器和给定的值不同,返回值可以是,也可以不是 {{jsxref("NaN")}} 。比如:</p>
-<pre class="brush: js line-numbers language-js"><code class="language-js">// 包含无效值的非 ISO 格式字符串
-new Date('23/25/2014');</code></pre>
+<pre class="brush: js line-numbers language-js">// 包含无效值的非 ISO 格式字符串
+new Date('23/25/2014');</pre>
<p>在 Firefox 30 中会被识别为本地时区的2015年12月25日,而在 Safari 7 中则是无效日期。但是,如果字符串被识别为 ISO 格式并且包含无效值,则在所有遵循 ES5 或者更新标准的浏览器中都会返回 {{jsxref("NaN")}} 。</p>
-<pre class="brush: js line-numbers language-js"><code class="language-js">// 包含无效值的 ISO 格式字符串
+<pre class="brush: js line-numbers language-js">// 包含无效值的 ISO 格式字符串
new Date('2014-25-23').toISOString();
-// 在所有遵循 ES5的浏览器中返回 "RangeError: invalid date"</code></pre>
+// 在所有遵循 ES5的浏览器中返回 "RangeError: invalid date"</pre>
<p>SpiderMonkey 的引擎策略可以在 <a href="http://mxr.mozilla.org/mozilla-central/source/js/src/jsdate.cpp?rev=64553c483cd1#889"><code>jsdate.cpp</code></a>  中找到。字符串 <code>"10 06 2014"</code>  可以作为非 ISO 格式字符串使用自定义处理方式的例子。参见这篇关于解析如何进行的<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1023155#c6">粗略纲要</a>。</p>
-<pre class="brush: js line-numbers language-js"><code class="language-js">new Date('10 06 2014');</code></pre>
+<pre class="brush: js line-numbers language-js">new Date('10 06 2014');</pre>
<p>将会被解析为本地时间 2014年10月6日,而不是6月10日。另一个例子</p>
-<pre class="brush: js line-numbers language-js"><code class="language-js">new Date('foo-bar 2014').toString();
+<pre class="brush: js line-numbers language-js">new Date('foo-bar 2014').toString();
// 返回: "Invalid Date"
Date.parse('foo-bar 2014');
-// 返回: NaN</code></pre>
+// 返回: NaN</pre>
<h2 id="Examples" name="Examples">例子</h2>
@@ -97,7 +97,7 @@ Date.parse('foo-bar 2014');
<p>如果 <code>IPOdate</code> 是一个已经存在的 {{jsxref("Date")}} 对象,则可以把其设置为本地时间 1995年8月9日。如下:</p>
-<pre class="brush: js line-numbers language-js"><code class="language-js">IPOdate.setTime(Date.parse('Aug 9, 1995'));</code></pre>
+<pre class="brush: js line-numbers language-js">IPOdate.setTime(Date.parse('Aug 9, 1995'));</pre>
<p>其他一些解析非标准格式日期的例子:</p>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/setfullyear/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/setfullyear/index.html
index c8fcb530ab..e5693e9e07 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/date/setfullyear/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/date/setfullyear/index.html
@@ -13,7 +13,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/setFullYear
<h2 id="Syntax" name="Syntax">语法</h2>
-<pre class="syntaxbox language-html"><code class="language-html">dateObj.setFullYear(yearValue[, monthValue[, dayValue]])</code></pre>
+<pre class="syntaxbox language-html">dateObj.setFullYear(yearValue[, monthValue[, dayValue]])</pre>
<h3 id="Parameters" name="Parameters">参数</h3>
@@ -36,8 +36,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/setFullYear
<h3 id="Example:_Using_setFullYear" name="Example:_Using_setFullYear">例子:使用<code>setFullYear</code>方法</h3>
-<pre class="brush:js language-js"><code class="language-js">var theBigDay = new Date();
-theBigDay.setFullYear(1997);</code></pre>
+<pre class="brush:js language-js">var theBigDay = new Date();
+theBigDay.setFullYear(1997);</pre>
<h2 id="规范">规范</h2>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/infinity/index.html b/files/zh-cn/web/javascript/reference/global_objects/infinity/index.html
index f20755f907..929985516d 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/infinity/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/infinity/index.html
@@ -25,11 +25,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Infinity
<h2 id="示例">示例</h2>
-<pre class="brush: js line-numbers language-js"><code class="language-js">console.log(Infinity ); /* Infinity */
+<pre class="brush: js line-numbers language-js">console.log(Infinity ); /* Infinity */
console.log(Infinity + 1 ); /* Infinity */
console.log(Math.pow(10, 1000)); /* Infinity */
console.log(Math.log(0) ); /* -Infinity */
-console.log(1 / Infinity ); /* 0 */</code></pre>
+console.log(1 / Infinity ); /* 0 */</pre>
<h2 id="规范">规范</h2>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/isfinite/index.html b/files/zh-cn/web/javascript/reference/global_objects/isfinite/index.html
index e69904ba41..cea70e68ee 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/isfinite/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/isfinite/index.html
@@ -33,7 +33,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/isFinite
<h2 id="Examples" name="Examples">示例</h2>
-<pre class="brush: js language-js"><code class="language-js">isFinite(Infinity); // false
+<pre class="brush: js language-js">isFinite(Infinity); // false
isFinite(NaN); // false
isFinite(-Infinity); // false
@@ -41,7 +41,7 @@ isFinite(0); // true
isFinite(2e64); // true, 在更强壮的Number.isFinite(null)中将会得到false
-isFinite("0"); // true, 在更强壮的Number.isFinite('0')中将会得到false</code></pre>
+isFinite("0"); // true, 在更强壮的Number.isFinite('0')中将会得到false</pre>
<div class="line-number"> </div>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/isnan/index.html b/files/zh-cn/web/javascript/reference/global_objects/isnan/index.html
index fac7d74714..1e23c1d0e4 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/isnan/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/isnan/index.html
@@ -48,10 +48,10 @@ translation_of: Web/JavaScript/Reference/Global_Objects/isNaN
<p>一个<code>isNaN</code>的 polyfill 可以理解为(这个polyfill利用了<code>NaN</code>自身永不相等于自身这一特征 ):</p>
-<pre class="brush: js line-numbers language-js"><code class="language-js">var isNaN = function(value) {
+<pre class="brush: js line-numbers language-js">var isNaN = function(value) {
var n = Number(value);
return n !== n;
-};</code></pre>
+};</pre>
<h2 id="Examples" name="Examples">示例</h2>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/pi/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/pi/index.html
index fcfc82fbd5..efc463d5b7 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/math/pi/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/math/pi/index.html
@@ -23,11 +23,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/PI
<p>下面的函数使用 Math.PI 计算给定半径的圆周长:</p>
-<pre class="brush:js language-js"><code class="language-js">function calculateCircumference (radius) {
+<pre class="brush:js language-js">function calculateCircumference (radius) {
return 2 * Math.PI * radius;
}
-calculateCircumference(1); // 6.283185307179586</code></pre>
+calculateCircumference(1); // 6.283185307179586</pre>
<h2 id="规范">规范</h2>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/random/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/random/index.html
index 91796ae506..04602b2699 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/math/random/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/math/random/index.html
@@ -50,11 +50,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/random
<p>这个例子返回了一个在指定值之间的随机整数。这个值不小于 <code>min</code> (如果 <code>min</code> 不是整数,则不小于 <code>min</code> 的向上取整数),且小于(不等于)<code>max</code>。</p>
-<pre class="brush: js line-numbers language-js"><code class="language-js">function getRandomInt(min, max) {
+<pre class="brush: js line-numbers language-js">function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
- return Math.floor(Math.random() * (max - min)) + min; </code>//不含最大值,含最小值<code class="language-js">
-}</code></pre>
+ return Math.floor(Math.random() * (max - min)) + min; //不含最大值,含最小值
+}</pre>
<div class="note">
<p>也许很容易想到用 <code>Math.round()</code> 来实现,但是这会导致你的随机数处于一个不均匀的分布,这可能不符合你的需求。</p>
@@ -64,11 +64,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/random
<p>上一个例子提到的函数 <code>getRandomInt()</code> 结果范围包含了最小值,但不含最大值。如果你的随机结果需要同时包含最小值和最大值,怎么办呢?  <code>getRandomIntInclusive()</code> 函数可以实现。</p>
-<pre class="brush: js line-numbers language-js"><code class="language-js">function getRandomIntInclusive(min, max) {
+<pre class="brush: js line-numbers language-js">function getRandomIntInclusive(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min; //含最大值,含最小值
-}</code></pre>
+}</pre>
<h2 id="规范">规范</h2>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/sign/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/sign/index.html
index 60808dde44..590089e3c1 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/math/sign/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/math/sign/index.html
@@ -50,12 +50,12 @@ Math.sign(); // NaN
<h2 id="Compatibility" name="Compatibility">Polyfill</h2>
-<pre class="brush: js language-js"><code class="language-js">function sign(x) {
+<pre class="brush: js language-js">function sign(x) {
x = +x ;// convert to a number
if (x === 0 || isNaN(x))
return x;
return x &gt; 0 ? 1 : -1;
-}</code></pre>
+}</pre>
<p> </p>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/getownpropertydescriptors/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/getownpropertydescriptors/index.html
index cc321fa788..22df48a042 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/object/getownpropertydescriptors/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/object/getownpropertydescriptors/index.html
@@ -41,14 +41,14 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDes
<p>创建子类的典型方法是定义子类,将其原型设置为超类的实例,然后在该实例上定义属性。这么写很不优雅,特别是对于 getters 和 setter 而言。 相反,您可以使用此代码设置原型:</p>
-<pre class="brush: js line-numbers language-js"><code class="language-js">function superclass() {}
+<pre class="brush: js line-numbers language-js">function superclass() {}
superclass.prototype = {
// 在这里定义方法和属性
};
function subclass() {}
subclass.prototype = Object.create(superclass.prototype, Object.getOwnPropertyDescriptors({
// 在这里定义方法和属性
-}));</code></pre>
+}));</pre>
<h2 id="规范">规范</h2>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/valueof/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/valueof/index.html
index e2627097bd..82d2bc61d9 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/object/valueof/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/object/valueof/index.html
@@ -147,7 +147,7 @@ console.log( str2.valueOf() === str2 ); // false</pre>
<h3 id="改写_.prototype.valueof">改写 .prototype.valueof</h3>
-<pre class="brush: js line-numbers language-js"><code class="language-js">function MyNumberType(n) {
+<pre class="brush: js line-numbers language-js">function MyNumberType(n) {
this.number = n;
}
@@ -156,7 +156,7 @@ MyNumberType.prototype.valueOf = function() {
};
var myObj = new MyNumberType(4);
-myObj + 3; // 7</code></pre>
+myObj + 3; // 7</pre>
<h2 id="规范">规范</h2>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/parsefloat/index.html b/files/zh-cn/web/javascript/reference/global_objects/parsefloat/index.html
index 21d4e0bfbd..f32b3bbf90 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/parsefloat/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/parsefloat/index.html
@@ -55,13 +55,13 @@ translation_of: Web/JavaScript/Reference/Global_Objects/parseFloat
<p>下面的例子都返回<strong>3.14</strong></p>
-<pre class="brush: js line-numbers language-js"><code class="language-js">parseFloat(3.14);
+<pre class="brush: js line-numbers language-js">parseFloat(3.14);
parseFloat('3.14');
parseFloat(' 3.14 ');
parseFloat('314e-2');
parseFloat('0.0314E+2');
parseFloat('3.14some non-digit characters');
-parseFloat({ toString: function() { return "3.14" } });</code></pre>
+parseFloat({ toString: function() { return "3.14" } });</pre>
<h3 id="parseFloat返回NaN"><code>parseFloat</code>返回NaN</h3>
@@ -74,8 +74,8 @@ parseFloat({ toString: function() { return "3.14" } });</code></pre>
<p>以下例子均返回 <code>900719925474099300</code>,当整数太大以至于不能被转换时将失去精度。</p>
-<pre class="brush: js line-numbers language-js"><code class="language-js">parseFloat(900719925474099267n);
-parseFloat('900719925474099267n');</code></pre>
+<pre class="brush: js line-numbers language-js">parseFloat(900719925474099267n);
+parseFloat('900719925474099267n');</pre>
<h2 id="规范">规范</h2>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/set/has/index.html b/files/zh-cn/web/javascript/reference/global_objects/set/has/index.html
index 0bbad115ec..47369b1f27 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/set/has/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/set/has/index.html
@@ -35,7 +35,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Set/has
<h3 id="Example:_Testing_size_of_all_array_elements" name="Example:_Testing_size_of_all_array_elements">使用 <code>has</code> 方法</h3>
-<pre class="brush: js line-numbers language-js"><code class="language-js">var mySet = new Set();
+<pre class="brush: js line-numbers language-js">var mySet = new Set();
mySet.add('foo');
mySet.has('foo'); // 返回 true
@@ -47,7 +47,7 @@ set1.add(obj1);
set1.has(obj1); // 返回 true
set1.has({'key1': 1}); // 会返回 false,因为其是另一个对象的引用
-set1.add({'key1': 1}); // 现在 set1 中有2条(不同引用的)对象了</code></pre>
+set1.add({'key1': 1}); // 现在 set1 中有2条(不同引用的)对象了</pre>
<h2 id="规范">规范</h2>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/match/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/match/index.html
index 33a3a57880..f369a7a7f9 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/string/match/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/string/match/index.html
@@ -60,7 +60,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/match
<p>在下例中,使用 <code>match</code> 查找 "<code>Chapter</code>" 紧跟着 1 个或多个数值字符,再紧跟着一个小数点和数值字符 0 次或多次。正则表达式包含 <code>i</code> 标志,因此大小写会被忽略。</p>
-<pre class="brush: js line-numbers language-js"><code class="language-js">var str = 'For more information, see Chapter 3.4.5.1';
+<pre class="brush: js line-numbers language-js">var str = 'For more information, see Chapter 3.4.5.1';
var re = /see (chapter \d+(\.\d)*)/i;
var found = str.match(re);
@@ -76,30 +76,30 @@ console.log(found);
// 'Chapter 3.4.5.1' 被'(chapter \d+(\.\d)*)'捕获。
// '.1' 是被'(\.\d)'捕获的最后一个值。
// 'index' 属性(22) 是整个匹配从零开始的索引。
-// 'input' 属性是被解析的原始字符串。</code></pre>
+// 'input' 属性是被解析的原始字符串。</pre>
<h3 id="Example_Using_global_and_ignore_case_flags_with_match" name="Example:_Using_global_and_ignore_case_flags_with_match">例子:<code>match</code> 使用全局(global)和忽略大小写(ignore case)标志</h3>
<p>下例展示了 <code>match</code> 使用 global 和 ignore case 标志。A-E、a-e 的所有字母将会作为一个数组的元素返回。</p>
-<pre class="brush: js line-numbers language-js"><code class="language-js">var str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
+<pre class="brush: js line-numbers language-js">var str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
var regexp = /[A-E]/gi;
var matches_array = str.match(regexp);
console.log(matches_array);
-// ['A', 'B', 'C', 'D', 'E', 'a', 'b', 'c', 'd', 'e']</code></pre>
+// ['A', 'B', 'C', 'D', 'E', 'a', 'b', 'c', 'd', 'e']</pre>
<h3 id="使用match,不传参数"><code>使用match(),不传参数 </code></h3>
-<pre class="brush: js line-numbers language-js"><code class="language-js">var str = "Nothing will come of nothing.";
+<pre class="brush: js line-numbers language-js">var str = "Nothing will come of nothing.";
-str.match(); // returns [""]</code></pre>
+str.match(); // returns [""]</pre>
<h3 id="一个非正则表达式对象作为参数">一个非正则表达式对象作为参数</h3>
<p>当参数是一个字符串或一个数字,它会使用new RegExp(obj)来隐式转换成一个 {{jsxref("RegExp")}}。如果它是一个有正号的正数,RegExp() 方法将忽略正号。</p>
-<pre class="brush: js line-numbers language-js"><code class="language-js">var str1 = "NaN means not a number. Infinity contains -Infinity and +Infinity in JavaScript.",
+<pre class="brush: js line-numbers language-js">var str1 = "NaN means not a number. Infinity contains -Infinity and +Infinity in JavaScript.",
str2 = "My grandfather is 65 years old and My grandmother is 63 years old.",
str3 = "The contract was declared null and void.";
str1.match("number"); // "number" 是字符串。返回["number"]
@@ -109,7 +109,7 @@ str1.match(+Infinity); // 返回["Infinity"]
str1.match(-Infinity); // 返回["-Infinity"]
str2.match(65); // 返回["65"]
str2.match(+65); // 有正号的number。返回["65"]
-str3.match(null); // 返回["null"]</code></pre>
+str3.match(null); // 返回["null"]</pre>
<h2 id="规范">规范</h2>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/padstart/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/padstart/index.html
index 98d0f201ed..c358da2585 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/string/padstart/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/string/padstart/index.html
@@ -35,17 +35,17 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/padStart
<h2 id="示例">示例</h2>
-<pre class="brush: js line-numbers language-js"><code class="language-js">'abc'.padStart(10); // " abc"
+<pre class="brush: js line-numbers language-js">'abc'.padStart(10); // " abc"
'abc'.padStart(10, "foo"); // "foofoofabc"
'abc'.padStart(6,"123465"); // "123abc"
'abc'.padStart(8, "0"); // "00000abc"
-'abc'.padStart(1); // "abc"</code></pre>
+'abc'.padStart(1); // "abc"</pre>
<h2 id="Polyfill">Polyfill</h2>
<p>如果原生环境不支持该方法,在其他代码之前先运行下面的代码,将创建 <code>String.prototype.padStart()</code> 方法。</p>
-<pre class="brush: js line-numbers language-js"><code class="language-js">// https://github.com/uxitten/polyfill/blob/master/string.polyfill.js
+<pre class="brush: js line-numbers language-js">// https://github.com/uxitten/polyfill/blob/master/string.polyfill.js
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart
if (!String.prototype.padStart) {
String.prototype.padStart = function padStart(targetLength,padString) {
@@ -62,7 +62,7 @@ if (!String.prototype.padStart) {
return padString.slice(0,targetLength) + String(this);
}
};
-}</code>
+}
</pre>
<h2 id="规范">规范</h2>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/repeat/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/repeat/index.html
index c0ee77fe21..e412b0da5c 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/string/repeat/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/string/repeat/index.html
@@ -44,7 +44,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/repeat
<p>此方法已添加到 ECMAScript 2015 规范中,并且可能尚未在所有 JavaScript 实现中可用。然而,你可以使用以下代码段对 String.prototype.repeat() 进行填充:</p>
-<pre class="brush: js language-js"><code class="language-js">if (!String.prototype.repeat) {
+<pre class="brush: js language-js">if (!String.prototype.repeat) {
String.prototype.repeat = function(count) {
'use strict';
if (this == null) {
@@ -83,7 +83,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/repeat
}
return rpt;
}
-}</code></pre>
+}</pre>
<h2 id="Examples" name="Examples">示例</h2>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/tolowercase/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/tolowercase/index.html
index 7db9f1e146..e8fd231457 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/string/tolowercase/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/string/tolowercase/index.html
@@ -15,7 +15,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/toLowerCase
<h2 id="语法">语法</h2>
-<pre class="syntaxbox language-html"><code class="language-html">str.toLowerCase()</code>
+<pre class="syntaxbox language-html">str.toLowerCase()
</pre>
<h3 id="返回值">返回值</h3>
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 fce5989dd7..38506cf5f0 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
@@ -150,9 +150,9 @@ typeof symObj; // "object"</pre>
<p> {{jsxref("Operators/typeof", "typeof")}}运算符能帮助你识别 symbol 类型</p>
-<pre class="brush: js"><code class="language-js">typeof Symbol() === 'symbol'
+<pre class="brush: js">typeof Symbol() === 'symbol'
typeof Symbol('foo') === 'symbol'
-typeof Symbol.iterator === 'symbol'</code>
+typeof Symbol.iterator === 'symbol'
</pre>
<h3 id="Symbol_类型转换">Symbol 类型转换</h3>
@@ -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"><code class="language-js">var obj = {};
+<pre class="brush: js line-numbers language-js">var obj = {};
obj[Symbol("a")] = "a";
obj[Symbol.for("b")] = "b";
@@ -179,14 +179,14 @@ obj.d = "d";
for (var i in obj) {
console.log(i); // logs "c" and "d"
-}</code></pre>
+}</pre>
<h3 id="Symbols_与_JSON.stringify">Symbols 与 <code>JSON.stringify()</code></h3>
<p>当使用 JSON.stringify() 时,以 symbol 值作为键的属性会被完全忽略:</p>
-<pre class="brush: js"><code class="language-js">JSON.stringify({[Symbol("foo")]: "foo"});
-// '{}'</code></pre>
+<pre class="brush: js">JSON.stringify({[Symbol("foo")]: "foo"});
+// '{}'</pre>
<p>更多细节,请看 {{jsxref("JSON.stringify()")}}。</p>
@@ -194,10 +194,10 @@ for (var i in obj) {
<p>当一个 Symbol 包装器对象作为一个属性的键时,这个对象将被强制转换为它包装过的 symbol 值:</p>
-<pre class="brush: js"><code class="language-js">var sym = Symbol("foo");
+<pre class="brush: js">var sym = Symbol("foo");
var obj = {[sym]: 1};
obj[sym]; // 1
-obj[Object(sym)]; // still 1</code></pre>
+obj[Object(sym)]; // still 1</pre>
<h2 id="规范">规范</h2>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/undefined/index.html b/files/zh-cn/web/javascript/reference/global_objects/undefined/index.html
index 20ff8d53a7..2748581673 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/undefined/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/undefined/index.html
@@ -101,9 +101,9 @@ if(y === undefined) { // ReferenceError: y is not defined
<p>但是,技术方面看来这样的使用方法应该被避免。JavaScript是一个静态作用域语言,所以,一个变量是否被声明可以通过看它是否在一个封闭的上下文中被声明。唯一的例外是全局作用域,但是全局作用域是被绑定在全局对象上的,所以要检查一个变量是否在全局上下文中存在可以通过检查全局对象上是否存在这个属性(比如使用{{jsxref("Operators/in", "in")}}操作符)。</p>
-<pre class="brush: js line-numbers language-js"><code class="language-js">if ('x' in window) {
+<pre class="brush: js line-numbers language-js">if ('x' in window) {
// 只有x被全局性的定义 才会这行这些语句
-}</code></pre>
+}</pre>
<h3 id="Void操作符和undefined">Void操作符和undefined</h3>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/webassembly/index.html b/files/zh-cn/web/javascript/reference/global_objects/webassembly/index.html
index 87978a0016..5ce3af745f 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/webassembly/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/webassembly/index.html
@@ -63,10 +63,10 @@ translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly
<p>下面的示例(请参见GitHub上的<a href="https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/instantiate-streaming.html">Instantiate-streaming.html</a>演示,并查看<a href="https://mdn.github.io/webassembly-examples/js-api-examples/instantiate-streaming.html">在线演示</a>)直接从流式底层源传输.wasm模块,然后对其进行编译和实例化,并通过<code>ResultObject</code>实现promise。 由于<code>instantiateStreaming()</code>函数接受对 {{domxref("Response")}} 对象的promise,因此您可以直接向其传递{{domxref("WindowOrWorkerGlobalScope.fetch()")}}调用,然后它将把返回的response传递给随后的函数。</p>
-<pre class="brush: js line-numbers language-js"><code class="language-js">var importObject = { imports: { imported_func: arg =&gt; console.log(arg) } };
+<pre class="brush: js line-numbers language-js">var importObject = { imports: { imported_func: arg =&gt; console.log(arg) } };
WebAssembly.instantiateStreaming(fetch('simple.wasm'), importObject)
-.then(obj =&gt; obj.instance.exports.exported_func())</code></pre>
+.then(obj =&gt; obj.instance.exports.exported_func())</pre>
<p>返回的<code>ResultObject</code>实例的成员可以被随后访问到,可以调用实例中被导出的方法。</p>