JavaScript this Keyword Quiz
In JavaScript, this depends on how a function is called, not where it’s defined. Arrow functions are the exception: they take this from the surrounding scope.
These questions cover methods, extracted functions, bind, call, apply and constructors.
this questions
- Why does this become undefined when you extract a method?
- Why does an arrow function method return undefined for this?
- Can you change this on a bound function with call()?
- Why does an arrow function in setTimeout keep this?
- What is the difference between call and apply in JavaScript?
- What happens when a constructor returns an object?
- Can call() change this in an arrow function?