Sometimes, we want to execute a method passed as parameter to function with JavaScript.
In this article, we’ll look at how to execute a method passed as parameter to function with JavaScript.
How to execute a method passed as parameter to function with JavaScript?
To execute a method passed as parameter to function with JavaScript, we just call the function.
For instance, we write
const myFunction = (param1, callbackFunction) => {
//...
callbackFunction();
};
to call callbackFunction
in myFunction
.
Conclusion
To execute a method passed as parameter to function with JavaScript, we just call the function.