My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

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

Dandy Cheng's photo
Dandy Cheng
·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?