How does an arrow function handle the "this" keyword differently than regular functions?
- Arrow functions inherit the "this" value from their containing scope.
- Arrow functions have their own "this" context.
- Arrow functions automatically bind "this" to the global object.
- Arrow functions can't use "this" keyword.
Arrow functions behave differently from regular functions when it comes to the "this" keyword. They inherit the "this" value from their containing lexical (surrounding) scope, while regular functions have their "this" determined by how they are called. This behavior can be advantageous in certain situations.
Loading...
Related Quiz
- The mechanism of closing over variables is a core concept in ________ programming in JavaScript.
- How do you denote a block of code to be executed if a condition is true?
- Which of the following best describes a JavaScript callback function?
- The _______ pattern allows a new object to be created by cloning an existing object to avoid the overhead of creating an object from scratch.
- The _______ method is used to handle errors in Promises.