From f629d8332271dc8314a68d13baa608710f0a0b88 Mon Sep 17 00:00:00 2001 From: terrierscript <13282103+terrierscript@users.noreply.github.com> Date: Fri, 3 May 2019 23:38:53 +0900 Subject: [PATCH] Append ES2019 flat() version --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 12cd423..ab3afe5 100644 --- a/README.md +++ b/README.md @@ -455,6 +455,9 @@ Flattens array a single level deep. const flatten = [1, [2, [3, [4]], 5]].reduce( (a, b) => a.concat(b), []) // => [1, 2, [3, [4]], 5] + // Native(ES2019) + const flatten = [1, [2, [3, [4]], 5]].flat() + // => [1, 2, [3, [4]], 5] ``` #### Browser Support for `Array.prototype.reduce()` @@ -481,6 +484,11 @@ Recursively flattens array. flattenDeep([1, [[2], [3, [4]], 5]]) // => [1, 2, 3, 4, 5] + + // Native(ES2019) + [1, [2, [3, [4]], 5]].flat(Infinity) + // => [1, 2, 3, 4, 5] + ``` #### Browser Support