Explain Higher-Order Functions in JavaScript
Where starting a function with the bracket is necessary else it will be considered as the normal function. The second set of parentheses is used to invoke the function because functions do not work without invoking.
Just like data types such as Number, Boolean, String is considered to be the data then functions can also work as data.
Functions can be passed through other functions
Functions can be set as object properties
Functions can be stored in arrays
Functions can be set as variables
Example:
function higher-order(fn)
{
fn();
}
higherOrder(function() { console.log(“Hi”) });
