You're debugging a JavaScript application and notice that a function defined within an object method using an arrow function is not behaving as expected. The "this" keyword is not referring to the object. What could be the reason for this?

  • Arrow functions always bind "this" to the object
  • Arrow functions don't have their own "this"
  • Objects cannot contain arrow functions
  • The object's properties are incorrectly defined
Arrow functions in JavaScript do not have their own "this" context. Instead, they inherit the "this" value from their containing function or the global context. If an arrow function is used inside an object method, it will use the "this" from the surrounding scope, which might not be the object itself.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *