Different ways to run JavaScript
- Using the browser console tab
- Using Node.js
- By creating Web Pages
Using the browser console tab
Almost every popular web browsers have built-in JavaScript engines. Where you can run JavaScript on a browser. To run JavaScript on browsers follow these steps
- Open your web browser (I'm using Google Chrome).
- Right-click on the display and select Inspect. (F12 shortcut).
- Now on the developer tools select the Console tab and then start writing your javascript code.
Node is a back-end run-time environment for executing JavaScript code. To run JS using Node.js, follow these steps:
- Install the latest version of Node.js.
- Install an IDE/Text Editor like Visual Studio Code. In VS code, create a file > write JS code > save it with the .js extension
By Creating Web Pages
- From inside the HTML file, we need to link the main.js file to use it. You can achieve that by adding the following code in main.html.
<script scr="main.js"></script>
- Open the main.html file using a browser.
- To check if our JS code ran or not, Right click on the web page > Inspect > Choose console tab
0 Comments:
Post a Comment
Do leave your comments