Categories
JavaScript Answers

How to call a JavaScript function from console?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *