From 01b0e12ba27b5069248fd09235e9a7143915ee30 Mon Sep 17 00:00:00 2001 From: Irvin Date: Wed, 16 Feb 2022 02:02:49 +0800 Subject: remove `notranslate` class in zh-CN --- .../reference/global_objects/array/from/index.html | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'files/zh-cn/web/javascript/reference/global_objects/array/from') 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

语法

-
Array.from(arrayLike[, mapFn[, thisArg]])
+
Array.from(arrayLike[, mapFn[, thisArg]])
 

参数

@@ -59,18 +59,18 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/from

String 生成数组

-
Array.from('foo');
+
Array.from('foo');
 // [ "f", "o", "o" ]

Set 生成数组

-
const set = new Set(['foo', 'bar', 'baz', 'foo']);
+
const set = new Set(['foo', 'bar', 'baz', 'foo']);
 Array.from(set);
 // [ "foo", "bar", "baz" ]

Map 生成数组

-
const map = new Map([[1, 2], [2, 4], [4, 8]]);
+
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());
 
 

从类数组对象(arguments)生成数组

-
function f() {
+
function f() {
   return Array.from(arguments);
 }
 
@@ -94,7 +94,7 @@ f(1, 2, 3);
 
 

Array.from 中使用箭头函数

-
// Using an arrow function as the map function to
+
// Using an arrow function as the map function to
 // manipulate the elements
 Array.from([1, 2, 3], x => x + x);
 // [2, 4, 6]
@@ -109,7 +109,7 @@ Array.from({length: 5}, (v, i) => i);
 
 

序列生成器(指定范围)

-
// Sequence generator function (commonly referred to as "range", e.g. Clojure, PHP etc)
+
// Sequence generator function (commonly referred to as "range", e.g. Clojure, PHP etc)
 const range = (start, stop, step) => Array.from({ length: (stop - start) / step + 1}, (_, i) => start + (i * step));
 
 // Generate numbers range 0..4
@@ -127,7 +127,7 @@ range('A'.charCodeAt(0), 'Z'.charCodeAt(0), 1).map(x => String.fromCharCode(x
 
 

数组去重合并

-
function combine(){
+
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]

ECMA-262 第六版标准中添加了 Array.from 。有些实现中可能尚未包括在其中。你可以通过在脚本前添加如下内容作为替代方法,以使用未原生支持的 Array.from 方法。该算法按照 ECMA-262 第六版中的规范实现,并假定 ObjectTypeError 有其本身的值, callback.call 对应 {{jsxref("Function.prototype.call")}} 。此外,鉴于无法使用 Polyfill 实现真正的的迭代器,该实现不支持规范中定义的泛型可迭代元素。

-
// Production steps of ECMA-262, Edition 6, 22.1.2.1
+
// Production steps of ECMA-262, Edition 6, 22.1.2.1
 if (!Array.from) {
   Array.from = (function () {
     var toStr = Object.prototype.toString;
-- 
cgit v1.2.3-54-g00ecf