Higher-Order Functions in JavaScript

JavaScript·2 min read·Jan 1, 2025

As opposed to a first-order function, a higher-order function is a function that takes other functions as argument:

function higherOrder(firstClass) {  // ...}

Or returns a function as its result:

function higherOrder() {  return function() {    // ...  }}

When supplied as an argument or returned as a value, these functions are called first-class functions.

Note: First-class functions that are typically executed in response to an event but not returned are usually called callback functions.

function higherOrder(callback) {  callback();}