Which JavaScript method is used to bind a function to a specific object?

  • .apply()
  • .bind()
  • .call()
  • .attach()
The .bind() method in JavaScript is used to create a new function that, when called, has its this keyword set to a specific object, allowing you to bind a function to that object. This is especially useful for ensuring the correct context when passing functions as callbacks or event handlers.
Add your answer
Loading...

Leave a comment

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