this
gets defined using by new
, or the object invoking this function, right?
Yes. And in this case, it's forEach
that invokes your function. Since no special precautions[1] are made, it simply passes nothing for this
[2] just like any non-method function call, which will result into the global object as your function is sloppy code[3].
1: Like passing a second argument to forEach
, which would be used for this
2: The spec says it should pass undefined
3: Meaning, that it does not use strict mode. In strict code, this
would literally really be undefined
.