Yes, a higher-order function is one that can accept other functions as arguments and/or return them as results. Here’s an example in JavaScript:
function higherOrderFunction(num) {
return function addFive() {
let result = higherOrderFunction(10);
console.log(result()); // Outputs: 15
In this code,
higherOrderFunction
is the higher-order function because it returns another function (
addFive
). The inner function uses a return statement to give back the result of adding five to whatever number was passed into the outer function.