I'm a little baffled. For some reason this won't work:
[1, 2, 3].forEach(function(num) {
console.log(num)
})
I get this error:
TypeError: Cannot call method 'forEach' of undefined
However, this will:
var nums = [1, 2, 3]
nums.forEach(function(num) {
console.log(num)
})
Anyone have any idea what's going on here?
Array.prototype.forEachright before the first statement? Does it output a function?var foo = 'bar' [1, 2, 3].forEach(function(num) { console.log(num) })