An issue arises when using Array.from as a callback with Array.flatMap, resulting in the error message: "TypeError: 0 is not a function"
const x = ["12"].flatMap(Array.from)
console.log(x)
However, when used as a regular function, Array.from operates normally:
const f = Array.from
console.log(f("12"))
To work around this issue, I discovered a solution:
const x = ["12"].flatMap(e => Array.from(e))
console.log(x)
My questions are:
- Why does this error occur?
- What makes the error message so unhelpful?