Beginner JavaScript Interview QuestionsBeginnerConcept
JavaScript · Question 17
What is a higher-order function in JavaScript?
Direct answer
A higher-order function is a function that takes one or more functions as arguments, returns a function, or both.
Because JavaScript functions are values, functions can operate on other functions. Array methods such as map, filter, and reduce are common higher-order functions because they receive callbacks.
A function can also return another function, such as const multiplyBy = a => b => a * b;. Calling multiplyBy(2) creates a new function specialized to multiply by two.