Loading...
const chars = words.values()
.flatMap((word) => word)
.toArray(); // TypeErrorconst chars = words.values()
.flatMap((word) => [...word])
.toArray();Iterator flatMap() rejects strings returned from the callback; spreading the string into an array yields its characters.
TypeError instead of splitting it.flatMap() on the iterator is used instead of building nested arrays first.flatMap() flatten?One level. Each value returned by the callback is iterated, but nested arrays inside it stay as they are.
flat() method?No. Use flatMap((x) => x) to flatten one level of iterables.