diff options
author | 3indblown Leaf <69508345+kraccoon-dev@users.noreply.github.com> | 2022-02-16 17:11:01 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-16 17:11:01 +0900 |
commit | c5e82bf41f336a59704ee8c429e3147f73fa8a48 (patch) | |
tree | 1329fd03f09c80a3fd39dfcf95bb480866252c8f /files/ko/web/javascript/reference/global_objects/array/flatmap | |
parent | 2968f00d257b512ac0d046a3fa12e8deec2540fb (diff) | |
download | translated-content-c5e82bf41f336a59704ee8c429e3147f73fa8a48.tar.gz translated-content-c5e82bf41f336a59704ee8c429e3147f73fa8a48.tar.bz2 translated-content-c5e82bf41f336a59704ee8c429e3147f73fa8a48.zip |
remove all span tags 1 (#3920)
Co-authored-by: Kyle <mkitigy@gmail.com>
Diffstat (limited to 'files/ko/web/javascript/reference/global_objects/array/flatmap')
-rw-r--r-- | files/ko/web/javascript/reference/global_objects/array/flatmap/index.html | 26 |
1 files changed, 13 insertions, 13 deletions
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 <h3 id="map_과_flatMap"><code>map</code> 과 <code>flatMap</code></h3> -<pre class="brush: js">let arr1 = <span class="js source"><span class="function-call js meta"><span class="js meta"><span class="brace js meta square"><span>[</span></span><span class="constant decimal js numeric"><span>1</span></span><span class="comma delimiter js meta object"><span>,</span></span><span> </span><span class="brace js meta square"><span>2, 3, 4]; +<pre class="brush: js">let arr1 = [1, 2, 3, 4]; -arr1.map(</span></span></span></span></span>x => [x * 2]<span class="js source"><span class="function-call js meta"><span class="js meta"><span class="brace js meta square"><span>);</span></span></span></span></span> +arr1.map(x => [x * 2]); // [[2], [4], [6], [8]] -arr1.flatMap(x => [x * 2]<span class="js source"><span class="function-call js meta"><span class="js meta"><span class="brace js meta square"><span>); -// [2, 4, 6, 8]</span></span></span></span></span> +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(" ")<span class="js source"><span class="function-call js meta"><span class="js meta"><span class="brace js meta square"><span>); -// ["it's","Sunny","in","California"]</span></span></span></span></span></pre> +arr1.flatMap(x => x.split(" ")); +// ["it's","Sunny","in","California"]</pre> <p>출력 리스트의 길이는 입력 리스트의 길이와 다를 수 있습니다.</p> @@ -93,21 +93,21 @@ a.flatMap( (n) => // expected output: [4, 1, 4, 20, 16, 1, 18]</code></pre> -<div class="line"><span class="js source"><span class="comment double-slash js line"><span class="comment definition js punctuation"><span>//</span></span><span>=> [1, 2, 3, 4, 5, 6, 7, 8, 9]</span></span></span></div> +<div class="line">//=> [1, 2, 3, 4, 5, 6, 7, 8, 9]</div> <h2 id="대안">대안</h2> <h3 id="reduce_와_concat"><code>reduce</code> 와 <code>concat</code></h3> -<pre class="brush: js">var arr1 = <span class="js source"><span class="function-call js meta"><span class="js meta"><span class="brace js meta square"><span>[</span></span><span class="constant decimal js numeric"><span>1</span></span><span class="comma delimiter js meta object"><span>,</span></span><span> </span><span class="brace js meta square"><span>2, 3, 4]; -</span></span></span></span></span> -arr1.flatMap(x => [x * 2]<span class="js source"><span class="function-call js meta"><span class="js meta"><span class="brace js meta square"><span>);</span></span></span></span></span> +<pre class="brush: js">var arr1 = [1, 2, 3, 4]; + +arr1.flatMap(x => [x * 2]); // 다음과 동일합니다 -arr1.reduce((acc, x) => acc.concat([x * 2]<span class="js source"><span class="function-call js meta"><span class="js meta"><span class="brace js meta square"><span>), []);</span></span></span></span></span> -<span class="js source"><span class="function-call js meta"><span class="js meta"><span class="brace js meta square"><span>// [2, 4, 6, 8]</span></span></span></span></span> +arr1.reduce((acc, x) => acc.concat([x * 2]), []); +// [2, 4, 6, 8] </pre> -<div class="line"><span class="js source"><span class="comment double-slash js line"><span class="comment definition js punctuation"><span>//</span></span><span>=> [1, 2, 3, 4, 5, 6, 7, 8, 9]</span></span></span></div> +<div class="line">//=> [1, 2, 3, 4, 5, 6, 7, 8, 9]</div> <h2 id="명세">명세</h2> |