var funcs = []
[1, 2].forEach( (i) => funcs.push( () => i ) )
Why does it produce the error below?
TypeError: Cannot read property 'forEach' of undefined
at Object.<anonymous>
However, the error goes away if the semicolon ; is added to the end of the first line.
var funcs = [][1, 2].forEach....map()instead of.forEach()at single linevar funcs = [1, 2].map( (i) => () => i )to avoid issue with semicolon