Your product could be here, in front of thousands of JavaScript developers. Sponsor this spot →
JavaScript Quiz

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

  1. Why does this become undefined when you extract a method?
  2. Why does an arrow function method return undefined for this?
  3. Can you change this on a bound function with call()?
  4. Why does an arrow function in setTimeout keep this?
  5. What is the difference between call and apply in JavaScript?
  6. What happens when a constructor returns an object?
  7. Can call() change this in an arrow function?

More topics