Higher order function that receives function as an argument CODE
Built-in built-in higher order functions that expect to receive a function as an argument
document.addEventListener('click', func);
function func() {
    alert('You clicked me!');
}
Using anonymous function:
document.addEventListener('click', function() {
    alert('You clicked me!');
});
Another built-in function
foreach
that receives a function as an argument
let greatColors = ['green', 'orange', 'yellow'];

greatColors.forEach(listColors);

function listColors(color) {
    document.write('The color ' + color + ' is a great color<br>');
}
by Valeri Tandilashvili
4 years ago
JavaScript
Higher order function
1
Pro tip: use ```triple backticks around text``` to write in code fences