I extremely confusing In forEach loop why the THIS will point to the obj.
I assume will output return this.id is undefined , because it called in a lexical function. THIS will point it to window.
function foo(el) {
console.log( el, this.id);
}
var obj = {
id: "awesome"
};
[1, 2, 3].forEach( foo, obj );
// 1 "awesome" 2 "awesome" 3 "awesome"
// Easy way to check
[1, 2, 3].forEach( function(el){
console.log( el, this.id);
}, obj);