aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/global_objects/array
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-cn/web/javascript/reference/global_objects/array')
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/array/concat/index.html10
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/array/every/index.html8
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/array/filter/index.html12
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/array/findindex/index.html6
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/array/flat/index.html18
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/array/flatmap/index.html10
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/array/from/index.html18
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/array/map/index.html24
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/array/reduce/index.html40
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/array/reduceright/index.html20
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/array/slice/index.html14
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/array/values/index.html12
12 files changed, 96 insertions, 96 deletions
diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/concat/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/concat/index.html
index 4541912a76..b0960c35d0 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/array/concat/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/array/concat/index.html
@@ -16,7 +16,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/concat
<h2 id="语法">语法</h2>
-<pre class="syntaxbox notranslate">var <var>new_array</var> = <var>old_array</var>.concat(<var>value1</var>[, <var>value2</var>[, ...[, <var>valueN</var>]]])</pre>
+<pre class="syntaxbox">var <var>new_array</var> = <var>old_array</var>.concat(<var>value1</var>[, <var>value2</var>[, ...[, <var>valueN</var>]]])</pre>
<h3 id="Parameters" name="Parameters">参数</h3>
@@ -53,7 +53,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/concat
<p>以下代码将两个数组合并为一个新数组:</p>
-<pre class="brush: js notranslate">var alpha = ['a', 'b', 'c'];
+<pre class="brush: js">var alpha = ['a', 'b', 'c'];
var numeric = [1, 2, 3];
alpha.concat(numeric);
@@ -63,7 +63,7 @@ alpha.concat(numeric);
<p>以下代码将三个数组合并为一个新数组:</p>
-<pre class="brush: js notranslate">var num1 = [1, 2, 3],
+<pre class="brush: js">var num1 = [1, 2, 3],
num2 = [4, 5, 6],
num3 = [7, 8, 9];
@@ -76,7 +76,7 @@ console.log(nums);
<p>以下代码将三个值连接到数组:</p>
-<pre class="brush: js notranslate">var alpha = ['a', 'b', 'c'];
+<pre class="brush: js">var alpha = ['a', 'b', 'c'];
var alphaNumeric = alpha.concat(1, [2, 3]);
@@ -87,7 +87,7 @@ console.log(alphaNumeric);
<p>以下代码合并数组并保留引用:</p>
-<pre class="brush: js notranslate">var num1 = [[1]];
+<pre class="brush: js">var num1 = [[1]];
var num2 = [2, [3]];
var num3=[5,[6]];
diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/every/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/every/index.html
index a64c25b43d..38d4388b52 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/array/every/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/array/every/index.html
@@ -24,7 +24,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/every
<h2 id="语法">语法</h2>
-<pre class="notranslate"><var>arr</var>.every(<var>callback</var>(<var>element</var>[, <var>index</var>[, <var>array</var>]])[, <var>thisArg</var>])</pre>
+<pre><var>arr</var>.every(<var>callback</var>(<var>element</var>[, <var>index</var>[, <var>array</var>]])[, <var>thisArg</var>])</pre>
<h3 id="参数">参数</h3>
@@ -68,7 +68,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/every
<p>下例检测数组中的所有元素是否都大于 10。</p>
-<pre class="brush: js notranslate">function isBigEnough(element, index, array) {
+<pre class="brush: js">function isBigEnough(element, index, array) {
return element &gt;= 10;
}
[12, 5, 8, 130, 44].every(isBigEnough); // false
@@ -79,14 +79,14 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/every
<p><a href="/zh-CN/docs/Web/JavaScript/Reference/Functions/Arrow_functions">箭头函数</a>为上面的检测过程提供了更简短的语法。</p>
-<pre class="brush: js notranslate">[12, 5, 8, 130, 44].every(x =&gt; x &gt;= 10); // false
+<pre class="brush: js">[12, 5, 8, 130, 44].every(x =&gt; x &gt;= 10); // false
[12, 54, 18, 130, 44].every(x =&gt; x &gt;= 10); // true</pre>
<h2 id="兼容旧环境(Polyfill)">兼容旧环境(Polyfill)</h2>
<p>在 ECMA-262 第 5 版时,<code>every</code> 被添加进 ECMA-262 标准;因此,在某些实现环境中,它尚未被支持。你可以把下面的代码放到脚本的开头来解决此问题,该代码允许在那些没有原生支持 <code>every</code> 的实现环境中使用它。该算法是 ECMA-262 第 5 版中指定的算法,它假定 <code>Object</code> 和 <code>TypeError</code> 拥有它们的初始值,且 <code>fun.call</code> 等价于 {{jsxref("Function.prototype.call")}}。</p>
-<pre class="brush: js notranslate">if (!Array.prototype.every) {
+<pre class="brush: js">if (!Array.prototype.every) {
Array.prototype.every = function(callbackfn, thisArg) {
'use strict';
var T, k;
diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/filter/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/filter/index.html
index c23bf5cb98..acc86a9592 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/array/filter/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/array/filter/index.html
@@ -20,7 +20,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/filter
<h2 id="语法">语法</h2>
-<pre class="syntaxbox notranslate"><var>var newArray = arr</var>.filter(<var>callback(element[, index[, array]])</var>[, <var>thisArg</var>])</pre>
+<pre class="syntaxbox"><var>var newArray = arr</var>.filter(<var>callback(element[, index[, array]])</var>[, <var>thisArg</var>])</pre>
<h3 id="参数">参数</h3>
@@ -69,7 +69,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/filter
<p>下例使用 <code>filter</code> 创建了一个新数组,该数组的元素由原数组中值大于 10 的元素组成。</p>
-<pre class="brush: js notranslate">function isBigEnough(element) {
+<pre class="brush: js">function isBigEnough(element) {
return element &gt;= 10;
}
var filtered = [12, 5, 8, 130, 44].filter(isBigEnough);
@@ -80,7 +80,7 @@ var filtered = [12, 5, 8, 130, 44].filter(isBigEnough);
<p>以下示例使用 <code>filter()</code> 创建具有非零 <code>id</code> 的元素的 json。</p>
-<pre class="brush: js notranslate">var arr = [
+<pre class="brush: js">var arr = [
{ id: 15 },
{ id: -1 },
{ id: 0 },
@@ -120,7 +120,7 @@ console.log('Number of Invalid Entries = ', invalidEntries);
<p>下例使用 <code>filter()</code> 根据搜索条件来过滤数组内容。</p>
-<pre class="brush: js notranslate">var fruits = ['apple', 'banana', 'grapes', 'mango', 'orange'];
+<pre class="brush: js">var fruits = ['apple', 'banana', 'grapes', 'mango', 'orange'];
/**
* Array filters items based on search criteria (query)
@@ -136,7 +136,7 @@ console.log(filterItems('an')); // ['banana', 'mango', 'orange']</pre>
<h4 id="ES2015_实现">ES2015 实现</h4>
-<pre class="brush: js notranslate">const fruits = ['apple', 'banana', 'grapes', 'mango', 'orange'];
+<pre class="brush: js">const fruits = ['apple', 'banana', 'grapes', 'mango', 'orange'];
/**
* Array filters items based on search criteria (query)
@@ -156,7 +156,7 @@ console.log(filterItems('an')); // ['banana', 'mango', 'orange']
<p><code>filter</code> 被添加到 ECMA-262 标准第 5 版中,因此在某些实现环境中不被支持。可以把下面的代码插入到脚本的开头来解决此问题,该代码允许在那些没有原生支持 <code>filter</code> 的实现环境中使用它。该算法是 ECMA-262 第 5 版中指定的算法,假定 <code>fn.call</code> 等价于 {{jsxref("Function.prototype.call")}} 的初始值,且 {{jsxref("Array.prototype.push")}} 拥有它的初始值。</p>
-<pre class="brush: js notranslate">if (!Array.prototype.filter){
+<pre class="brush: js">if (!Array.prototype.filter){
Array.prototype.filter = function(func, thisArg) {
'use strict';
if ( ! ((typeof func === 'Function' || typeof func === 'function') &amp;&amp; this) )
diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/findindex/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/findindex/index.html
index 7b1e3c7143..b0c8967e8e 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/array/findindex/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/array/findindex/index.html
@@ -20,7 +20,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/findIndex
<h2 id="Syntax" name="Syntax">语法</h2>
-<pre class="syntaxbox notranslate"><code><em>arr</em>.findIndex(<em>callback</em>[, <em>thisArg</em>])</code></pre>
+<pre class="syntaxbox"><code><em>arr</em>.findIndex(<em>callback</em>[, <em>thisArg</em>])</code></pre>
<h3 id="Parameters" name="Parameters">参数</h3>
@@ -62,7 +62,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/findIndex
<p>以下示例查找数组中素数的元素的索引(如果不存在素数,则返回-1)。</p>
-<pre class="brush: js notranslate">function isPrime(element, index, array) {
+<pre class="brush: js">function isPrime(element, index, array) {
var start = 2;
while (start &lt;= Math.sqrt(element)) {
if (element % start++ &lt; 1) {
@@ -77,7 +77,7 @@ console.log([4, 6, 7, 12].findIndex(isPrime)); // 2</pre>
<h2 id="Polyfill">Polyfill</h2>
-<pre class="brush: js notranslate">// https://tc39.github.io/ecma262/#sec-array.prototype.findIndex
+<pre class="brush: js">// https://tc39.github.io/ecma262/#sec-array.prototype.findIndex
if (!Array.prototype.findIndex) {
Object.defineProperty(Array.prototype, 'findIndex', {
value: function(predicate) {
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 2f37e8f49b..f6a9420e21 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
@@ -19,7 +19,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/flat
<h2 id="语法">语法</h2>
-<pre class="syntaxbox notranslate"><var>var newArray = arr</var>.flat([<var>depth]</var>)</pre>
+<pre class="syntaxbox"><var>var newArray = arr</var>.flat([<var>depth]</var>)</pre>
<h3 id="参数">参数</h3>
@@ -36,7 +36,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/flat
<h3 id="扁平化嵌套数组">扁平化嵌套数组</h3>
-<pre class="notranslate">var arr1 = [1, 2, [3, 4]];
+<pre>var arr1 = [1, 2, [3, 4]];
arr1.flat();
// [1, 2, 3, 4]
@@ -57,7 +57,7 @@ arr4.flat(Infinity);
<p><code>flat()</code> 方法会移除数组中的空项:</p>
-<pre class="brush: js notranslate">var arr4 = [1, 2, , 4, 5];
+<pre class="brush: js">var arr4 = [1, 2, , 4, 5];
arr4.flat();
// [1, 2, 4, 5]</pre>
@@ -65,7 +65,7 @@ arr4.flat();
<h3 id="使用_reduce_与_concat">使用 <code>reduce</code> 与 <code>concat</code></h3>
-<pre class="notranslate"><code>var arr = [1, 2, [3, 4]];
+<pre><code>var arr = [1, 2, [3, 4]];
// 展开一层数组
arr.flat();
@@ -78,7 +78,7 @@ 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 notranslate"><code>// 使用 reduce、concat 和递归展开无限多层嵌套的数组
+<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) {
@@ -91,7 +91,7 @@ flatDeep(arr1, Infinity);
<h3 id="forEachisArraypushrecursivity">forEach+isArray+push+recursivity</h3>
-<pre class="brush: js notranslate">// forEach 遍历数组会自动跳过空元素
+<pre class="brush: js">// forEach 遍历数组会自动跳过空元素
const eachFlat = (arr = [], depth = 1) =&gt; {
  const result = []; // 缓存递归结果
  // 开始递归
@@ -131,7 +131,7 @@ const forFlat = (arr = [], depth = 1) =&gt; {
<h3 id="使用堆栈stack">使用堆栈stack</h3>
-<pre class="notranslate">// 无递归数组扁平化,使用堆栈
+<pre>// 无递归数组扁平化,使用堆栈
// 注意:深度的控制比较低效,因为需要检查每一个值的深度
// 也可能在 shift / unshift 上进行 w/o 反转,但是末端的数组 OPs 更快
var arr1 = [1,2,3,[1,2,3,4, [2,3,4]]];
@@ -153,7 +153,7 @@ function flatten(input) {
}
flatten(arr1);// [1, 2, 3, 1, 2, 3, 4, 2, 3, 4]</pre>
-<pre class="notranslate">// 递归版本的反嵌套
+<pre>// 递归版本的反嵌套
function flatten(array) {
var flattend = [];
(function flat(array) {
@@ -167,7 +167,7 @@ function flatten(array) {
<h3 id="Use_Generator_function">Use <code>Generator</code> function</h3>
-<pre class="notranslate"><code>function* flatten(array) {
+<pre><code>function* flatten(array) {
for (const item of array) {
if (Array.isArray(item)) {
yield* flatten(item);
diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/flatmap/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/flatmap/index.html
index 50c75a73ab..8383d4be6a 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/array/flatmap/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/array/flatmap/index.html
@@ -19,7 +19,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/flatMap
<h2 id="语法">语法</h2>
-<pre class="syntaxbox notranslate"><var>var new_array = arr</var>.flatMap(function <var>callback(currentValue[, index[, array]]) {
+<pre class="syntaxbox"><var>var new_array = arr</var>.flatMap(function <var>callback(currentValue[, index[, array]]) {
// return element for new_array
}</var>[, <var>thisArg</var>])</pre>
@@ -54,7 +54,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/flatMap
<h3 id="map_与_flatMap"><code>map()</code> 与 <code>flatMap()</code></h3>
-<pre class="brush: js notranslate">var arr1 = [1, 2, 3, 4];
+<pre class="brush: js">var arr1 = [1, 2, 3, 4];
arr1.map(x =&gt; [x * 2]);
// [[2], [4], [6], [8]]
@@ -70,7 +70,7 @@ arr1.flatMap(x =&gt; [[x * 2]]);
<p>所以,为了更好的展示 flatMap 的作用,下面我们将包含几句话的数组拆分成单个词组成的新数组。</p>
-<pre class="notranslate"><code>let arr1 = ["it's Sunny in", "", "California"];
+<pre><code>let arr1 = ["it's Sunny in", "", "California"];
arr1.map(x =&gt; x.split(" "));
// [["it's","Sunny","in"],[""],["California"]]
@@ -84,7 +84,7 @@ arr1.flatMap(x =&gt; x.split(" "));
<p><code>flatMap</code> 能用于在map期间增删项目(也就是修改items的数量)。换句话说,它允许你遍历很多项使之成为另一些项(靠分别把它们放进去来处理),而不是总是一对一。 从这个意义上讲,它的作用类似于 <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter">filter</a>的对立面。只需返回一个1项元素数组以保留该项,返回一个多元素数组以添加项,或返回一个0项元素数组以删除该项。</p>
-<pre class="notranslate"><code>// Let's say we want to remove all the negative numbers and split the odd numbers into an even number and a 1
+<pre><code>// Let's say we want to remove all the negative numbers and split the odd numbers into an even number and a 1
let a = [5, 4, -3, 20, 17, -33, -4, 18]
// |\ \ x | | \ x x |
// [4,1, 4, 20, 16, 1, 18]
@@ -101,7 +101,7 @@ a.flatMap( (n) =&gt;
<h3 id="reduce_与_concat"><code>reduce()</code> 与 <code>concat()</code></h3>
-<pre class="notranslate"><code>var arr = [1, 2, 3, 4];
+<pre><code>var arr = [1, 2, 3, 4];
arr.flatMap(x =&gt; [x, x * 2]);
// is equivalent to
diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/from/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/from/index.html
index 8cab100d7c..01b6062f91 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/array/from/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/array/from/index.html
@@ -22,7 +22,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/from
<h2 id="语法">语法</h2>
-<pre class="syntaxbox notranslate">Array.from(<em>arrayLike</em>[, <em>mapFn</em>[, <em>thisArg</em>]])
+<pre class="syntaxbox">Array.from(<em>arrayLike</em>[, <em>mapFn</em>[, <em>thisArg</em>]])
</pre>
<h3 id="参数">参数</h3>
@@ -59,18 +59,18 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/from
<h3 id="从_String_生成数组">从 <code>String</code> 生成数组</h3>
-<pre class="brush: js notranslate">Array.from('foo');
+<pre class="brush: js">Array.from('foo');
// [ "f", "o", "o" ]</pre>
<h3 id="从_Set_生成数组">从 <code>Set</code> 生成数组</h3>
-<pre class="brush: js notranslate">const set = new Set(['foo', 'bar', 'baz', 'foo']);
+<pre class="brush: js">const set = new Set(['foo', 'bar', 'baz', 'foo']);
Array.from(set);
// [ "foo", "bar", "baz" ]</pre>
<h3 id="从_Map_生成数组">从 <code>Map</code> 生成数组</h3>
-<pre class="brush: js notranslate">const map = new Map([[1, 2], [2, 4], [4, 8]]);
+<pre class="brush: js">const map = new Map([[1, 2], [2, 4], [4, 8]]);
Array.from(map);
// [[1, 2], [2, 4], [4, 8]]
@@ -84,7 +84,7 @@ Array.from(mapper.keys());
<h3 id="从类数组对象(arguments)生成数组">从类数组对象(arguments)生成数组</h3>
-<pre class="brush: js notranslate">function f() {
+<pre class="brush: js">function f() {
return Array.from(arguments);
}
@@ -94,7 +94,7 @@ f(1, 2, 3);
<h3 id="在_Array.from_中使用箭头函数">在 <code>Array.from</code> 中使用箭头函数</h3>
-<pre class="brush: js notranslate">// Using an arrow function as the map function to
+<pre class="brush: js">// Using an arrow function as the map function to
// manipulate the elements
Array.from([1, 2, 3], x =&gt; x + x);
// [2, 4, 6]
@@ -109,7 +109,7 @@ Array.from({length: 5}, (v, i) =&gt; i);
<h3 id="序列生成器指定范围">序列生成器(指定范围)</h3>
-<pre class="brush: js notranslate">// Sequence generator function (commonly referred to as "range", e.g. Clojure, PHP etc)
+<pre class="brush: js">// Sequence generator function (commonly referred to as "range", e.g. Clojure, PHP etc)
const range = (start, stop, step) =&gt; Array.from({ length: (stop - start) / step + 1}, (_, i) =&gt; start + (i * step));
// Generate numbers range 0..4
@@ -127,7 +127,7 @@ range('A'.charCodeAt(0), 'Z'.charCodeAt(0), 1).map(x =&gt; String.fromCharCode(x
<h3 id="数组去重合并">数组去重合并</h3>
-<pre class="brush: js notranslate">function combine(){
+<pre class="brush: js">function combine(){
let arr = [].concat.apply([], arguments); //没有去重复的新数组
return Array.from(new Set(arr));
}
@@ -139,7 +139,7 @@ console.log(combine(m,n)); // [1, 2, 3]</pre>
<p>ECMA-262 第六版标准中添加了 <code>Array.from </code>。有些实现中可能尚未包括在其中。你可以通过在脚本前添加如下内容作为替代方法,以使用未原生支持的 <code>Array.from</code> 方法。该算法按照 ECMA-262 第六版中的规范实现,并假定 <code>Object</code> 和 <code>TypeError</code> 有其本身的值, <code>callback.call</code> 对应 {{jsxref("Function.prototype.call")}} 。此外,鉴于无法使用 Polyfill 实现真正的的迭代器,该实现不支持规范中定义的泛型可迭代元素。</p>
-<pre class="brush: js notranslate">// Production steps of ECMA-262, Edition 6, 22.1.2.1
+<pre class="brush: js">// Production steps of ECMA-262, Edition 6, 22.1.2.1
if (!Array.from) {
Array.from = (function () {
var toStr = Object.prototype.toString;
diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/map/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/map/index.html
index b00ce5df07..1517622c81 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/array/map/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/array/map/index.html
@@ -20,7 +20,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/map
<h2 id="Syntax" name="Syntax">语法</h2>
-<pre class="notranslate"><var>var new_array = arr</var>.map(function <var>callback(currentValue[, index[, array]]) {
+<pre><var>var new_array = arr</var>.map(function <var>callback(currentValue[, index[, array]]) {
// Return element for new_array </var>
<var>}</var>[, <var>thisArg</var>])</pre>
@@ -68,7 +68,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/map
<p>下面的代码创建了一个新数组,值为原数组中对应数字的平方根。</p>
-<pre class="brush: js notranslate">var numbers = [1, 4, 9];
+<pre class="brush: js">var numbers = [1, 4, 9];
var roots = numbers.map(Math.sqrt);
// roots的值为[1, 2, 3], numbers的值仍为[1, 4, 9]</pre>
@@ -76,7 +76,7 @@ var roots = numbers.map(Math.sqrt);
<p>以下代码使用一个包含对象的数组来重新创建一个格式化后的数组。</p>
-<pre class="brush: js notranslate">var kvArray = [{key: 1, value: 10},
+<pre class="brush: js">var kvArray = [{key: 1, value: 10},
{key: 2, value: 20},
{key: 3, value: 30}];
@@ -98,7 +98,7 @@ var reformattedArray = kvArray.map(function(obj) {
<p>下面的代码表示了当函数需要一个参数时map的工作方式。当map循环遍历原始数组时,这个参数会自动被分配成数组中对应的每个元素。</p>
-<pre class="brush: js notranslate">var numbers = [1, 4, 9];
+<pre class="brush: js">var numbers = [1, 4, 9];
var doubles = numbers.map(function(num) {
return num * 2;
});
@@ -110,7 +110,7 @@ var doubles = numbers.map(function(num) {
<p>下面的例子演示如何在一个 {{jsxref("String")}}  上使用 map 方法获取字符串中每个字符所对应的 ASCII 码组成的数组:</p>
-<pre class="brush: js notranslate">var map = Array.prototype.map
+<pre class="brush: js">var map = Array.prototype.map
var a = map.call("Hello World", function(x) {
  return x.charCodeAt(0);
})
@@ -121,7 +121,7 @@ var a = map.call("Hello World", function(x) {
<p>下面代码展示了如何去遍历用 <code>querySelectorAll </code>得到的动态对象集合。在这里,我们获得了文档里所有选中的选项,并将其打印:</p>
-<pre class="brush: js notranslate">var elems = document.querySelectorAll('select option:checked');
+<pre class="brush: js">var elems = document.querySelectorAll('select option:checked');
var values = Array.prototype.map.call(elems, function(obj) {
return obj.value;
});
@@ -135,7 +135,7 @@ var values = Array.prototype.map.call(elems, function(obj) {
<p>考虑下例:</p>
-<pre class="notranslate"><code>["1", "2", "3"].map(parseInt);</code></pre>
+<pre><code>["1", "2", "3"].map(parseInt);</code></pre>
<p>我们期望输出 <code>[1, 2, 3]</code>, 而实际结果是 <code>[1, NaN, NaN]</code>.</p>
@@ -149,14 +149,14 @@ var values = Array.prototype.map.call(elems, function(obj) {
<p>第三个参数被parseInt忽视了, <u>but not the second one</u>, 但不是第二个。因此可能出现混淆。下面是迭代步骤的简明示例:</p>
-<pre class="notranslate"><code>// parseInt(string, radix) -&gt; map(parseInt(value, index))
+<pre><code>// parseInt(string, radix) -&gt; map(parseInt(value, index))
/* first iteration (index is 0): */ parseInt("1", 0); // 1
/* second iteration (index is 1): */ parseInt("2", 1); // NaN
/* third iteration (index is 2): */ parseInt("3", 2); // NaN</code></pre>
<p>下面让我们来讨论解决方案:</p>
-<pre class="notranslate"><code>function returnInt(element) {
+<pre><code>function returnInt(element) {
return parseInt(element, 10);
}
@@ -176,7 +176,7 @@ var values = Array.prototype.map.call(elems, function(obj) {
<p>一个map方法调用 parseInt 作为一个参数的等效输出运行如下:</p>
-<pre class="notranslate"><code>var xs = ['10', '10', '10'];
+<pre><code>var xs = ['10', '10', '10'];
xs = xs.map(parseInt);
@@ -187,7 +187,7 @@ console.log(xs); // 输出结果为</code>(3) [10, NaN, 2]<code>
<p>当返回undefined 或没有返回任何内容时:</p>
-<pre class="notranslate"><code>var numbers = [1, 2, 3, 4];
+<pre><code>var numbers = [1, 2, 3, 4];
var filteredNumbers = numbers.map(function(num, index) {
if(index &lt; 3) {
return num;
@@ -201,7 +201,7 @@ var filteredNumbers = numbers.map(function(num, index) {
<p><code>map</code> was added to the ECMA-262 standard in the 5th edition; as such it may not be present in all implementations of the standard. You can work around this by inserting the following code at the beginning of your scripts, allowing use of <code>map</code> in implementations which do not natively support it. This algorithm is exactly the one specified in ECMA-262, 5th edition, assuming {{jsxref("Object")}}, {{jsxref("TypeError")}}, and {{jsxref("Array")}} have their original values and that <code>callback.call</code> evaluates to the original value of <code>{{jsxref("Function.prototype.call")}}</code>.</p>
-<pre class="notranslate"><code>// Production steps of ECMA-262, Edition 5, 15.4.4.19
+<pre><code>// Production steps of ECMA-262, Edition 5, 15.4.4.19
// Reference: http://es5.github.io/#x15.4.4.19
if (!Array.prototype.map) {
diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/reduce/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/reduce/index.html
index f356bceaf6..cc217e28af 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/array/reduce/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/array/reduce/index.html
@@ -36,7 +36,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/Reduce
<h2 id="语法">语法</h2>
-<pre class="notranslate"><var>arr.reduce(callback(accumulator, currentValue[, index[, array]])[, initialValue])</var></pre>
+<pre><var>arr.reduce(callback(accumulator, currentValue[, index[, array]])[, initialValue])</var></pre>
<h3 id="参数">参数</h3>
@@ -89,7 +89,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/Reduce
<p>提供初始值通常更安全,正如下面的例子,如果没有提供<code>initialValue</code>,则可能有四种输出:</p>
-<pre class="brush: js notranslate">var maxCallback = ( acc, cur ) =&gt; Math.max( acc.x, cur.x );
+<pre class="brush: js">var maxCallback = ( acc, cur ) =&gt; Math.max( acc.x, cur.x );
var maxCallback2 = ( max, cur ) =&gt; Math.max( max, cur );
// reduce() 没有初始值
@@ -107,7 +107,7 @@ var maxCallback2 = ( max, cur ) =&gt; Math.max( max, cur );
<p>假如运行下段<code>reduce()</code>代码:</p>
-<pre class="brush:js notranslate">[0, 1, 2, 3, 4].reduce(function(accumulator, currentValue, currentIndex, array){
+<pre class="brush:js">[0, 1, 2, 3, 4].reduce(function(accumulator, currentValue, currentIndex, array){
return accumulator + currentValue;
});
</pre>
@@ -172,11 +172,11 @@ var maxCallback2 = ( max, cur ) =&gt; Math.max( max, cur );
<p>你还可以使用{{jsxref("Functions/Arrow_functions", "箭头函数","",1)}}来代替完整的函数。 下面的代码将产生与上面的代码相同的输出:</p>
-<pre class="brush: js notranslate">[0, 1, 2, 3, 4].reduce((prev, curr) =&gt; prev + curr );</pre>
+<pre class="brush: js">[0, 1, 2, 3, 4].reduce((prev, curr) =&gt; prev + curr );</pre>
<p>如果你打算提供一个初始值作为<code>reduce()</code>方法的第二个参数,以下是运行过程及结果:</p>
-<pre class="brush: js notranslate">[0, 1, 2, 3, 4].reduce((accumulator, currentValue, currentIndex, array) =&gt; {
+<pre class="brush: js">[0, 1, 2, 3, 4].reduce((accumulator, currentValue, currentIndex, array) =&gt; {
return accumulator + currentValue
}, 10)
</pre>
@@ -332,14 +332,14 @@ var maxCallback2 = ( max, cur ) =&gt; Math.max( max, cur );
<h3 id="数组里所有值的和">数组里所有值的和</h3>
-<pre class="brush: js notranslate">var sum = [0, 1, 2, 3].reduce(function (accumulator, currentValue) {
+<pre class="brush: js">var sum = [0, 1, 2, 3].reduce(function (accumulator, currentValue) {
return accumulator + currentValue;
}, 0);
// 和为 6</pre>
<p>你也可以写成箭头函数的形式:</p>
-<pre class="brush: js notranslate">var total = [ 0, 1, 2, 3 ].reduce(
+<pre class="brush: js">var total = [ 0, 1, 2, 3 ].reduce(
( acc, cur ) =&gt; acc + cur,
0
);</pre>
@@ -348,7 +348,7 @@ var maxCallback2 = ( max, cur ) =&gt; Math.max( max, cur );
<p>要累加对象数组中包含的值,必须提供初始值,以便各个item正确通过你的函数。</p>
-<pre class="brush: js notranslate">var initialValue = 0;
+<pre class="brush: js">var initialValue = 0;
var sum = [{x: 1}, {x:2}, {x:3}].reduce(function (accumulator, currentValue) {
return accumulator + currentValue.x;
},initialValue)
@@ -357,7 +357,7 @@ console.log(sum) // logs 6</pre>
<p>你也可以写成箭头函数的形式:</p>
-<pre class="brush: js notranslate">var initialValue = 0;
+<pre class="brush: js">var initialValue = 0;
var sum = [{x: 1}, {x:2}, {x:3}].reduce(
(accumulator, currentValue) =&gt; accumulator + currentValue.x
,initialValue
@@ -368,7 +368,7 @@ console.log(sum) // logs 6
<h3 id="将二维数组转化为一维">将二维数组转化为一维</h3>
-<pre class="brush: js notranslate">var flattened = [[0, 1], [2, 3], [4, 5]].reduce(
+<pre class="brush: js">var flattened = [[0, 1], [2, 3], [4, 5]].reduce(
function(a, b) {
return a.concat(b);
},
@@ -379,7 +379,7 @@ console.log(sum) // logs 6
<p>你也可以写成箭头函数的形式:</p>
-<pre class="brush: js notranslate">var flattened = [[0, 1], [2, 3], [4, 5]].reduce(
+<pre class="brush: js">var flattened = [[0, 1], [2, 3], [4, 5]].reduce(
( acc, cur ) =&gt; acc.concat(cur),
[]
);
@@ -388,7 +388,7 @@ console.log(sum) // logs 6
<h3 id="计算数组中每个元素出现的次数">计算数组中每个元素出现的次数</h3>
-<pre class="brush: js notranslate">var names = ['Alice', 'Bob', 'Tiff', 'Bruce', 'Alice'];
+<pre class="brush: js">var names = ['Alice', 'Bob', 'Tiff', 'Bruce', 'Alice'];
var countedNames = names.reduce(function (allNames, name) {
if (name in allNames) {
@@ -404,7 +404,7 @@ var countedNames = names.reduce(function (allNames, name) {
<h3 id="按属性对object分类">按属性对object分类</h3>
-<pre class="brush: js notranslate">var people = [
+<pre class="brush: js">var people = [
{ name: 'Alice', age: 21 },
{ name: 'Max', age: 20 },
{ name: 'Jane', age: 20 }
@@ -434,7 +434,7 @@ var groupedPeople = groupBy(people, 'age');
<h3 id="使用扩展运算符和initialValue绑定包含在对象数组中的数组">使用扩展运算符和initialValue绑定包含在对象数组中的数组</h3>
-<pre class="brush: js notranslate">// friends - 对象数组
+<pre class="brush: js">// friends - 对象数组
// where object field "books" - list of favorite books
var friends = [{
name: 'Anna',
@@ -469,7 +469,7 @@ var allbooks = friends.reduce(function(prev, curr) {
<p>注意: 如果你正在使用一个可以兼容{{jsxref("Set")}} 和 {{jsxref("Array.from()")}} 的环境, 你可以使用<code>let orderedArray = Array.from(new Set(myArray));</code> 来获得一个相同元素被移除的数组。</p>
</div>
-<pre class="brush: js notranslate">let myArray = ['a', 'b', 'a', 'b', 'c', 'e', 'e', 'c', 'd', 'd', 'd', 'd']
+<pre class="brush: js">let myArray = ['a', 'b', 'a', 'b', 'c', 'e', 'e', 'c', 'd', 'd', 'd', 'd']
let myOrderedArray = myArray.reduce(function (accumulator, currentValue) {
if (accumulator.indexOf(currentValue) === -1) {
accumulator.push(currentValue)
@@ -479,7 +479,7 @@ let myOrderedArray = myArray.reduce(function (accumulator, currentValue) {
console.log(myOrderedArray)</pre>
-<pre class="brush: js notranslate">let arr = [1,2,1,2,3,5,4,5,3,4,4,4,4];
+<pre class="brush: js">let arr = [1,2,1,2,3,5,4,5,3,4,4,4,4];
let result = arr.sort().reduce((init, current) =&gt; {
if(init.length === 0 || init[init.length-1] !== current) {
  init.push(current);
@@ -490,7 +490,7 @@ console.log(result); //[1,2,3,4,5]</pre>
<h3 id="按顺序运行Promise">按顺序运行Promise</h3>
-<pre class="brush: js notranslate">/**
+<pre class="brush: js">/**
* Runs promises from array of functions that can return promises
* in chained manner
*
@@ -537,7 +537,7 @@ runPromiseInSequence(promiseArr, 10)
<h3 id="功能型函数管道">功能型函数管道</h3>
-<pre class="brush: js notranslate">// Building-blocks to use for composition
+<pre class="brush: js">// Building-blocks to use for composition
const double = x =&gt; x + x;
const triple = x =&gt; 3 * x;
const quadruple = x =&gt; 4 * x;
@@ -563,7 +563,7 @@ multiply24(10); // 240
<h3 id="使用_reduce实现map">使用 reduce实现map</h3>
-<pre class="brush: js notranslate">if (!Array.prototype.mapUsingReduce) {
+<pre class="brush: js">if (!Array.prototype.mapUsingReduce) {
Array.prototype.mapUsingReduce = function(callback, thisArg) {
return this.reduce(function(mappedArray, currentValue, index, array) {
mappedArray[index] = callback.call(thisArg, currentValue, index, array)
@@ -579,7 +579,7 @@ multiply24(10); // 240
<h2 id="Polyfill">Polyfill</h2>
-<pre class="brush: js notranslate">// Production steps of ECMA-262, Edition 5, 15.4.4.21
+<pre class="brush: js">// Production steps of ECMA-262, Edition 5, 15.4.4.21
// Reference: http://es5.github.io/#x15.4.4.21
// https://tc39.github.io/ecma262/#sec-array.prototype.reduce
if (!Array.prototype.reduce) {
diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/reduceright/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/reduceright/index.html
index 94ef4c7602..1245486db3 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/array/reduceright/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/array/reduceright/index.html
@@ -20,7 +20,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/ReduceRight
<h2 id="语法">语法</h2>
-<pre class="syntaxbox notranslate"><var>arr.reduceRight(callback(accumulator, currentValue[, index[, array]])[, initialValue])</var></pre>
+<pre class="syntaxbox"><var>arr.reduceRight(callback(accumulator, currentValue[, index[, array]])[, initialValue])</var></pre>
<h3 id="参数">参数</h3>
@@ -55,7 +55,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/ReduceRight
<p>可以像下面这样调用 <code>reduceRight</code> 的回调函数 <code>callback</code>:</p>
-<pre class="brush: js notranslate">array.reduceRight(function(accumulator, currentValue, index, array) {
+<pre class="brush: js">array.reduceRight(function(accumulator, currentValue, index, array) {
// ...
});</pre>
@@ -111,7 +111,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/ReduceRight
<p>该函数的完整执行过程见下例:</p>
-<pre class="brush: js notranslate">[0, 1, 2, 3, 4].reduceRight(function(previousValue, currentValue, index, array) {
+<pre class="brush: js">[0, 1, 2, 3, 4].reduceRight(function(previousValue, currentValue, index, array) {
return previousValue + currentValue;
});
</pre>
@@ -169,7 +169,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/ReduceRight
<p>如果提供了一个 <code>initialValue</code> 参数,则结果如下:</p>
-<pre class="brush: js notranslate">[0, 1, 2, 3, 4].reduceRight(function(previousValue, currentValue, index, array) {
+<pre class="brush: js">[0, 1, 2, 3, 4].reduceRight(function(previousValue, currentValue, index, array) {
return previousValue + currentValue;
}, 10);
</pre>
@@ -235,14 +235,14 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/ReduceRight
<h3 id="求一个数组中所有值的和">求一个数组中所有值的和</h3>
-<pre class="brush: js notranslate">var sum = [0, 1, 2, 3].reduceRight(function(a, b) {
+<pre class="brush: js">var sum = [0, 1, 2, 3].reduceRight(function(a, b) {
return a + b;
});
// sum is 6</pre>
<h3 id="扁平化(flatten)一个二维数组">扁平化(flatten)一个二维数组</h3>
-<pre class="brush: js notranslate">var flattened = [[0, 1], [2, 3], [4, 5]].reduceRight(function(a, b) {
+<pre class="brush: js">var flattened = [[0, 1], [2, 3], [4, 5]].reduceRight(function(a, b) {
return a.concat(b);
}, []);
// flattened is [4, 5, 2, 3, 0, 1]
@@ -250,7 +250,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/ReduceRight
<h3 id="运行一个带有回调每个函数将其结果传给下一个的异步函数列表">运行一个带有回调每个函数将其结果传给下一个的异步函数列表</h3>
-<pre class="brush: js notranslate">const waterfall = (...functions) =&gt; (callback, ...args) =&gt;
+<pre class="brush: js">const waterfall = (...functions) =&gt; (callback, ...args) =&gt;
functions.reduceRight(
(composition, fn) =&gt; (...results) =&gt; fn(composition, ...results),
callback
@@ -293,7 +293,7 @@ const computation2 = (input, callback) =&gt; {
<h3 id="展示_reduce_与_reduceRight_之间的区别">展示 <code>reduce</code> 与 <code>reduceRight</code> 之间的区别</h3>
-<pre class="brush: js notranslate">var a = ['1', '2', '3', '4', '5'];
+<pre class="brush: js">var a = ['1', '2', '3', '4', '5'];
var left = a.reduce(function(prev, cur) { return prev + cur; });
var right = a.reduceRight(function(prev, cur) { return prev + cur; });
@@ -304,7 +304,7 @@ console.log(right); // "54321"</pre>
<p>组合函数的概念简单,它只是简单地结合了多个函数。它是一个从右向左流动的函数,用上一个函数的输出调用每个函数。</p>
-<pre class="brush: js notranslate">/**
+<pre class="brush: js">/**
* Function Composition is way in which result of one function can
* be passed to another and so on.
*
@@ -333,7 +333,7 @@ console.log(compose(inc, double)(2)); // 5</pre>
<p><code>reduceRight</code> 被添加到 ECMA-262 标准第 5 版,因此它在某些实现环境中可能不被支持。把下面的代码添加到脚本开头可以解决此问题,从而允许在那些没有原生支持 <code>reduceRight</code> 的实现环境中使用它。</p>
-<pre class="brush: js notranslate">// Production steps of ECMA-262, Edition 5, 15.4.4.22
+<pre class="brush: js">// Production steps of ECMA-262, Edition 5, 15.4.4.22
// Reference: http://es5.github.io/#x15.4.4.22
if ('function' !== typeof Array.prototype.reduceRight) {
Array.prototype.reduceRight = function(callback /*, initialValue*/) {
diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/slice/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/slice/index.html
index eb68df4907..b69293d1db 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/array/slice/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/array/slice/index.html
@@ -20,7 +20,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/slice
<h2 id="语法">语法</h2>
-<pre class="syntaxbox notranslate"><var>arr</var>.slice([<var>begin</var>[, <var>end</var>]])</pre>
+<pre class="syntaxbox"><var>arr</var>.slice([<var>begin</var>[, <var>end</var>]])</pre>
<h2 id="参数">参数</h2>
@@ -63,7 +63,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/slice
<h3 id="返回现有数组的一部分">返回现有数组的一部分</h3>
-<pre class="brush: js notranslate">var fruits = ['Banana', 'Orange', 'Lemon', 'Apple', 'Mango'];
+<pre class="brush: js">var fruits = ['Banana', 'Orange', 'Lemon', 'Apple', 'Mango'];
var citrus = fruits.slice(1, 3);
// fruits contains ['Banana', 'Orange', 'Lemon', 'Apple', 'Mango']
@@ -78,7 +78,7 @@ var citrus = fruits.slice(1, 3);
<p>在下例中, <code>slice</code> 从 <code>myCar</code> 中创建了一个新数组<code>newCar</code>。两个数组都包含了一个 <code>myHonda</code> 对象的引用。当 <code>myHonda</code> 的 <code>color</code> 属性改变为 <code>purple</code>,则两个数组中的对应元素都会随之改变。</p>
-<pre class="brush: js notranslate">// 使用 slice 方法从 myCar 中创建一个 newCar。
+<pre class="brush: js">// 使用 slice 方法从 myCar 中创建一个 newCar。
var myHonda = { color: 'red', wheels: 4, engine: { cylinders: 4, size: 2.2 } };
var myCar = [myHonda, 2, "cherry condition", "purchased 1997"];
var newCar = myCar.slice(0, 2);
@@ -100,7 +100,7 @@ console.log('newCar[0].color = ' + newCar[0].color);
<p>上述代码输出:</p>
-<pre class="brush: js notranslate"> myCar = [{color: 'red', wheels: 4, engine: {cylinders: 4, size: 2.2}}, 2,
+<pre class="brush: js"> myCar = [{color: 'red', wheels: 4, engine: {cylinders: 4, size: 2.2}}, 2,
'cherry condition', 'purchased 1997']
newCar = [{color: 'red', wheels: 4, engine: {cylinders: 4, size: 2.2}}, 2]
myCar[0].color = red
@@ -114,7 +114,7 @@ newCar[0].color = purple
<p><code>slice</code> 方法可以用来将一个类数组(Array-like)对象/集合转换成一个新数组。你只需将该方法绑定到这个对象上。 一个函数中的  {{jsxref("Functions/arguments", "arguments")}} 就是一个类数组对象的例子。</p>
-<pre class="brush: js notranslate">function list() {
+<pre class="brush: js">function list() {
return Array.prototype.slice.call(arguments);
}
@@ -123,7 +123,7 @@ var list1 = list(1, 2, 3); // [1, 2, 3]
<p>除了使用 <code>Array.prototype.slice.call(</code><code>arguments</code><code>)</code>,你也可以简单的使用 <code>[].slice.call(arguments)</code> 来代替。另外,你可以使用 <code>bind</code> 来简化该过程。</p>
-<pre class="brush: js notranslate">var unboundSlice = Array.prototype.slice;
+<pre class="brush: js">var unboundSlice = Array.prototype.slice;
var slice = Function.prototype.call.bind(unboundSlice);
function list() {
@@ -137,7 +137,7 @@ var list1 = list(1, 2, 3); // [1, 2, 3]
<p>根据规范,使用 <code>Array.prototype.slice</code> 转换宿主对象(如 DOM 对象)时,不必遵循 Mozilla 的默认行为,即可以转化任何符合条件的伪数组宿主对象为数组,IE &lt; 9 没有遵循,而 IE9 + 遵循这个行为,但是稍加改造可以使其在跨浏览器使用时更可靠。只要其他现代浏览器继续支持该行为,目前 IE 9+、FireFox、Chrome、Safari 以及 Opera 都支持,开发者在使用下面代码时遍历 DOM 时就不会被该方法的字面意义误导,即 IE &lt; 9 不能转化 DOM Collections。开发者可以安全地根据语义知道该方法的实际上的标准行为。(下面的代码还修正了 IE 中 <code>slice()</code> 方法第二个参数不允许为显式的 {{jsxref("Global_Objects/null", "null")}}/{{jsxref("Global_Objects/undefined", "undefined")}} 值的问题,其他现代浏览器,包括 IE9+ 都允许)。</p>
-<pre class="brush: js notranslate">/**
+<pre class="brush: js">/**
* Shim for "fixing" IE's lack of support (IE &lt; 9) for applying slice
* on host objects like NamedNodeMap, NodeList, and HTMLCollection
* (technically, since host objects have been implementation-dependent,
diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/values/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/values/index.html
index 7af8b40436..d8cc03f53f 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/array/values/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/array/values/index.html
@@ -20,7 +20,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/values
<h2 id="语法">语法</h2>
-<pre class="syntaxbox notranslate"><var>arr</var>.values()</pre>
+<pre class="syntaxbox"><var>arr</var>.values()</pre>
<h3 id="返回值">返回值</h3>
@@ -30,7 +30,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/values
<h3 id="使用_for...of_循环进行迭代">使用 <code>for...of</code> 循环进行迭代</h3>
-<pre class="brush: js notranslate">let arr = ['w', 'y', 'k', 'o', 'p'];
+<pre class="brush: js">let arr = ['w', 'y', 'k', 'o', 'p'];
let eArr = arr.values();
for (let letter of eArr) {
@@ -39,11 +39,11 @@ for (let letter of eArr) {
<p><strong>Array.prototype.values</strong> 是 <strong>Array.prototype[Symbol.iterator] </strong>的默认实现。</p>
-<pre class="notranslate">Array.prototype.values === Array.prototype[Symbol.iterator] // true </pre>
+<pre>Array.prototype.values === Array.prototype[Symbol.iterator] // true </pre>
<h3 id="使用_.next_迭代">使用 <code>.next()</code> 迭代</h3>
-<pre class="notranslate">var arr = ['a', 'b', 'c', 'd', 'e'];
+<pre>var arr = ['a', 'b', 'c', 'd', 'e'];
var iterator = arr.values();
iterator.next(); // Object { value: "a", done: false }
iterator.next().value; // "b"
@@ -59,7 +59,7 @@ iterator.next().value; // undefined</pre>
<p>例子:</p>
-<pre class="notranslate">var arr = ['a', 'b', 'c', 'd', 'e'];
+<pre>var arr = ['a', 'b', 'c', 'd', 'e'];
var iterator = arr.values();
for (let letter of iterator) {
console.log(letter);
@@ -72,7 +72,7 @@ console.log(letter);
<p><strong>值</strong>: 数组迭代器中存储的是原数组的地址,而不是数组元素值。</p>
-<pre class="notranslate">var arr = ['a', 'b', 'c', 'd', 'e'];
+<pre>var arr = ['a', 'b', 'c', 'd', 'e'];
var iterator = arr.values();
console.log(iterator); // Array Iterator { }
iterator.next().value; // "a"