Well that's very interesting.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach
You can include a second argument for the this
object when calling forEach
. If not provided, this
will be limited to the same scope as if you were simply to write for (var i in arr) {.. }
. I suspect they did this so that the forEach
function behaves as closely to a built-in syntactical feature of JS as possible.