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.
Add your answer
Loading...

Leave a comment

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