Sometimes, we want to call a JavaScript function from console.
In this article, we’ll look at how to call a JavaScript function from console.
How to call a JavaScript function from console?
To call a JavaScript function from console, we just type in the code to define the function and call it.
For instance, we type
const myFunction = () => {
alert("doing something!");
};
myFunction();
into the console to define the myFunction
function and call it.
Then we should see an alert box that shows ‘doing something!’.
Conclusion
To call a JavaScript function from console, we just type in the code to define the function and call it.