Sign in
Log inSign up

What does the last parameter (this) do in the forEach function?

Deactivated User's photo
Deactivated User
·Sep 15, 2017

e.g.

[1,2,3].forEach(function(x){
    console.log(k[x])
},this)

I also realized that I get an undefined after looping the array. Why is that?