While reading through a JavaScript codebase, you see a function that is returned from another function and retains access to its lexical scope, even after the outer function has finished execution. What is this pattern called?
- Callback
- Promise
- IIFE (Immediately Invoked Function Expression)
- Higher-order Function
This pattern is known as a "Higher-order Function." In JavaScript, higher-order functions are functions that can take other functions as arguments or return them. This enables functions to maintain access to their lexical scope, creating closures.
Loading...
Related Quiz
- The _________ method of an XMLHttpRequest object is used to send the request to a server.
- The ________ initiative aimed to standardize the core features of JavaScript.
- Which array method adds elements to the beginning of an array?
- Which of the following is NOT a state of a Promise?
- To prevent variables from being added to the global object, it is common to use a(n) _______ function expression.