flatMap배열
map 후 1단계 평탄화합니다.
문법
arr.flatMap(callbackFn)예제
아래 값을 입력하면 예제에 즉시 반영됩니다.
const→sentences→words→flatMap→split→console→const sentences = ["Hello World", "Foo Bar"];
const words = sentences.flatMap((s) => s.split(" "));
console.log(words); // ["Hello", "World", "Foo", "Bar"]