Can an arrow function have its own this context?
- Yes, it has its own this context
- No, it shares the this context with the surrounding code
- Yes, but it inherits the this context from the parent scope
- No, it always refers to the global object
Yes, an arrow function has its own this context, which means it does not bind its own this but retains the this value of the enclosing lexical scope. This behavior can be advantageous in certain scenarios.
Loading...
Related Quiz
- In what scenario would a callback be more appropriate than a Promise?
- In ES6, setting "type": "______" in package.json informs Node.js to treat JavaScript files as ES modules.
- What is the significance of the done property in the object returned by the next() method of a generator?
- Can a module have both named and default exports?
- Q2: If you are managing a group of user objects, each with associated metadata, how would using a WeakMap affect memory management compared to using a Map?