- Home
- /
- Tutorials
- /
- JavaScript Tutorial
- /
- JavaScript Higher Order Functions
JavaScript Functions
JavaScript Higher Order Functions
A JavaScript higher order function is a function that takes a function as an argument or returns one.
This is possible because functions in JavaScript are values, just like numbers and strings.
You have already used higher order functions if you have used map or filter.
Example
Example
javascript
function applyTwice(value, action) {
return action(action(value));
}
console.log(applyTwice(3, n => n * 2));