What is Higher Order Function in JavaScript ?
Last Updated :
29 Jan, 2024
A higher-order function is a function that can accept a function as one of its parameters and it can also return a function as its return value or it can do both return as well as accept a function. A higher-order function can also take as well as return other types of values but it either has to take a function as a parameter or return a function as its return value with them. It can be declared using any syntax available in JavaScript to declare functions.
Example: The below code explains how you can declare higher-order functions in JavaScript.
Javascript
function higherOrderFunc(a){
return function (b){
console.log(a*b)
}
}
higherOrderFunc(3)(53);
|
Share your thoughts in the comments
Please Login to comment...