JavaScript this Keyword Behavior in Arrow vs Normal Functions

Understanding "this" as a core (Arrow vs Normal Function) Many times confusion around this comes from thinking it depends on where a function is written, but in reality it depends on how the function is called. In the example below, the outer function is called as an object method, so its this refers to the object itself. The inner function is an arrow function, which does not create its own this and instead lexically inherits it from the parent function. This small distinction cleared a lot of confusion for me around this behavior in JavaScript . If the inner function were a normal function instead of an arrow function, the value of this would be different. #JavaScript #LearningInPublic #WebDevelopment #Frontend #NodeJS

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories