From c5e82bf41f336a59704ee8c429e3147f73fa8a48 Mon Sep 17 00:00:00 2001 From: 3indblown Leaf <69508345+kraccoon-dev@users.noreply.github.com> Date: Wed, 16 Feb 2022 17:11:01 +0900 Subject: remove all span tags 1 (#3920) Co-authored-by: Kyle --- .../global_objects/array/flatmap/index.html | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'files/ko/web/javascript/reference/global_objects/array/flatmap/index.html') diff --git a/files/ko/web/javascript/reference/global_objects/array/flatmap/index.html b/files/ko/web/javascript/reference/global_objects/array/flatmap/index.html index 93d92580b8..3e85dde980 100644 --- a/files/ko/web/javascript/reference/global_objects/array/flatmap/index.html +++ b/files/ko/web/javascript/reference/global_objects/array/flatmap/index.html @@ -49,13 +49,13 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/flatMap

mapflatMap

-
let arr1 = [1, 2, 3, 4];
+
let arr1 = [1, 2, 3, 4];
 
-arr1.map(x => [x * 2]);
+arr1.map(x => [x * 2]);
 // [[2], [4], [6], [8]]
 
-arr1.flatMap(x => [x * 2]);
-// [2, 4, 6, 8]
+arr1.flatMap(x => [x * 2]);
+// [2, 4, 6, 8]
 
 // 한 레벨만 평탄화됨
 arr1.flatMap(x => [[x * 2]]);
@@ -71,8 +71,8 @@ arr1.flatMap(x => [[x * 2]]);
 arr1.map(x=>x.split(" "));
 // [["it's","Sunny","in"],[""],["California"]]
 
-arr1.flatMap(x => x.split(" "));
-// ["it's","Sunny","in","California"]
+arr1.flatMap(x => x.split(" ")); +// ["it's","Sunny","in","California"]

출력 리스트의 길이는 입력 리스트의 길이와 다를 수 있습니다.

@@ -93,21 +93,21 @@ a.flatMap( (n) => // expected output: [4, 1, 4, 20, 16, 1, 18] -
//=> [1, 2, 3, 4, 5, 6, 7, 8, 9]
+
//=> [1, 2, 3, 4, 5, 6, 7, 8, 9]

대안

reduceconcat

-
var arr1 = [1, 2, 3, 4];
-
-arr1.flatMap(x => [x * 2]);
+
var arr1 = [1, 2, 3, 4];
+
+arr1.flatMap(x => [x * 2]);
 // 다음과 동일합니다
-arr1.reduce((acc, x) => acc.concat([x * 2]), []);
-// [2, 4, 6, 8]
+arr1.reduce((acc, x) => acc.concat([x * 2]), []);
+// [2, 4, 6, 8]
 
-
//=> [1, 2, 3, 4, 5, 6, 7, 8, 9]
+
//=> [1, 2, 3, 4, 5, 6, 7, 8, 9]

명세

-- cgit v1.2.3-54-g00ecf