Why does "this" keyword not working on arrow functions? | SoloLearn: Learn to code for FREE!

+2

Why does "this" keyword not working on arrow functions?

Watch this code https://code.sololearn.com/WYnCU1S2Y2nR/?ref=app

2/17/2020 3:07:27 AM

Maxx

1 Answer

New Answer

+6

arrow functions don't have their own `this`. If `this` is used inside arrow function then lexical scoping is used to resolve the binding and `this` refers to surrounding environment. In your code just replace `this.name` with `this` only (on line 3). it's referring to Window Object and not the `human` object.