The function hi is a function that has a single parameter -- a function. The function displays 'hi' according to the specified outputFunction that is passed to the function hi.
function hi(outputFunction) {
let x = 'hi'
outputFunction(x);
}
hi(alert)hi(console.log)hi(myAlert), where
myAlert is a user-defined functionAn anonymous function is a function that does not have a name
hi(function(x) {
alert('anonymous alert says: ' + x);
});
Note that this is equivalent to hi(myFunction), where
myFunction = function(x) {
alert('anonymous alert says: ' + x);
}