7
嘗試將Array.from
傳遞給Array.prototype.map
時出現奇怪的錯誤。Array.from TypeError:0不是函數
let fn = Array.from.bind(Array); // [Function: bound from]
fn('test') // [ 't', 'e', 's', 't' ]
['test'].map(s => fn(s)) // [ [ 't', 'e', 's', 't' ] ]
['test'].map(fn) // TypeError: 0 is not a function
完全錯誤:
TypeError: 0 is not a function
at Function.from (native)
at Array.map (native)
at repl:1:10
at REPLServer.defaultEval (repl.js:260:27)
at bound (domain.js:287:14)
at REPLServer.runBound [as eval] (domain.js:300:12)
at REPLServer.<anonymous> (repl.js:429:12)
at emitOne (events.js:95:20)
at REPLServer.emit (events.js:182:7)
at REPLServer.Interface._onLine (readline.js:211:10)
這是怎麼回事?