findIndex
flat
flatMap
ネストした配列を平坦化します。
arr.flat(depth?)
下記の値を入力するとサンプルに即時反映されます。
const
nested
console
const nested = [1, [2, 3], [4, [5, 6]]]; console.log(nested.flat()); // [1, 2, 3, 4, [5, 6]] console.log(nested.flat(2)); // [1, 2, 3, 4, 5, 6]