Lexically Scoped this and arguments

Learn the lexical behavior of this and arguments in arrow functions and their dynamic behavior in anonymous functions.

Lexical scoped this

Anonymous functions use dynamic scoping for this and arguments and use lexical scoping for all other variables. This behavior often causes error and unpleasant workarounds. Recall that rest parameters are preferable to arguments in modern JavaScript, but the this keyword is still a nemesis.

Dynamic scoped this in anonymous functions

Let’s look at an example that illustrates the odd behavior of this.

Get hands-on with 1400+ tech skills courses.