function otherfunction (arg){
console.log(arg);
}
function executeFunction(otherfunction){
}
executeFunction(otherfunction(
"hello")
);
This seems redudant , suggestions??
function otherfunction (arg){
console.log(arg);
}
function executeFunction(otherfunction){
}
executeFunction(otherfunction(
"hello")
);
This seems redudant , suggestions??
In this example, it is redundant. However, in other cases, you can pass another function signature to the executeFunction() function, though that seems excessive unless the function to be called may be dynamically determined due to other things. In any case, do explain what you are trying to accomplish. In the C/C++ and other languages, this is called passing a function pointer to execute in the called function's body, perhaps using variables that the called function has, or knows about, or was passed when called.
Just a note: the function 'executeFunction' is not executing anything. In your code, the argument recieved as otherFunction in the executeFunction will be the return of execution of the defined function otherFunction.
What exactly are you trying to achieve?
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.