Consider I have four functions:
function first() {
console.log("This is the first function");
}
function second() {
console.log("This is the second function");
}
function third() {
console.log("This is the third function");
}
function fourth(name) {
console.log("This is the fourth function " + name);
}
I am trying to pass the above list of functions to a function:
var list_of_functions = [first, second, third, fourth];
executeFunctions(list_of_functions);
This is the executeFunction
:
function executeFunctions(list_of_functions) {
console.log("inside new executeFunctions");
list_of_functions.forEach(function(entry) {
entry();
});
}
How do I pass the name argument for my fourth
function in the array itself ? Is there any way to do this ?
For example, I would like to do something like this:
var list_of_functions = [first, second, third, fourth("Mike")];
Obviously, the above statement is wrong. Is there any way to do this ?