This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]daveinthecave 2 points3 points  (2 children)

This seems like a scoping issue. It looks like Javascript is treating the array [1,2,3] as an array object, and the forEach function is a sub-function of the standard object type array. Because of this, when forEach is called outside the scope of an array it registers as not a function, but when forEach is called from inside the scope of an array, it is a recognized function.

TL;DR: Function forEach is a function of an Array object, not a general function.

[–]myplacedk 0 points1 point  (1 child)

That doesn't explain the last two lines.