Higher order function in java script

Defination

*Any function which is taking another function as a argument that function is called HOF.
*Function are called HOF only if it takes minimum one function as a argument.
*Array.map, Array.filter, and Array.reduce are common higher-o…


This content originally appeared on DEV Community and was authored by T Shiva Kumar

Defination

*Any function which is taking another function as a argument that function is called HOF.
*Function are called HOF only if it takes minimum one function as a argument.
*Array.map, Array.filter, and Array.reduce are common higher-order functions that take a callback function as an argument.

syntax:

function myfunction(name,city){

}
myfunction(function(){},function(){});

Example

function fun(callback1, callback2) {
callback1();
callback2();
}

// Example functions to pass as arguments
function sayHello() {
console.log('Hello!');
}

function sayGoodbye() {
console.log('Goodbye!');
}

// Calling 'fun' with two functions as arguments
fun(sayHello, sayGoodbye);

// Output:
// Hello!
// Goodbye!

Not a Higher order function

function f1(x){
--------------------
}
f1(100);
*Because it does not take function as a argument.


This content originally appeared on DEV Community and was authored by T Shiva Kumar


Print Share Comment Cite Upload Translate Updates
APA

T Shiva Kumar | Sciencx (2024-08-17T11:19:41+00:00) Higher order function in java script. Retrieved from https://www.scien.cx/2024/08/17/higher-order-function-in-java-script/

MLA
" » Higher order function in java script." T Shiva Kumar | Sciencx - Saturday August 17, 2024, https://www.scien.cx/2024/08/17/higher-order-function-in-java-script/
HARVARD
T Shiva Kumar | Sciencx Saturday August 17, 2024 » Higher order function in java script., viewed ,<https://www.scien.cx/2024/08/17/higher-order-function-in-java-script/>
VANCOUVER
T Shiva Kumar | Sciencx - » Higher order function in java script. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/08/17/higher-order-function-in-java-script/
CHICAGO
" » Higher order function in java script." T Shiva Kumar | Sciencx - Accessed . https://www.scien.cx/2024/08/17/higher-order-function-in-java-script/
IEEE
" » Higher order function in java script." T Shiva Kumar | Sciencx [Online]. Available: https://www.scien.cx/2024/08/17/higher-order-function-in-java-script/. [Accessed: ]
rf:citation
» Higher order function in java script | T Shiva Kumar | Sciencx | https://www.scien.cx/2024/08/17/higher-order-function-in-java-script/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.