In this tutorial, you will learn about various approaches to run JavaScript on your computer.

What is JavaScript?

JavaScript is an extremely amazing client-side scripting language. JavaScript is used predominantly for upgrading the interaction of a user with the webpage. In other words, you can make your website page all the more exuberant and intuitive, with the assistance of JavaScript. JavaScript is likewise being used generally in game development and Mobile application development.

Javascript History

JavaScript was developed by Brendan Eich in 1995, which showed up in Netscape, a popular browser of that time.

The language was at first called LiveScript and was later renamed JavaScript. There are numerous programmers who imagine that JavaScript and Java are the equivalent. In fact, JavaScript and Java are very much unrelated. Java is a very complex programming language while JavaScript is just a scripting language. The syntax of JavaScript is generally impacted by the programming language C.


How to Run JavaScript?

JavaScript is a famous programming language that has a wide range of applications.

JavaScript was previously used essentially for making webpages intuitive, for example, form validation, animation, and so on These days, JavaScript is also used in numerous different areas, for example, server side development, mobile application development, etc.

On account of its wide range of applications, you can run JavaScript severally:

• Using console tab of internet browsers

• Using Node.js

• By making web pages


1. Using Console Tab of Web Browsers

All popular internet browsers have implicit JavaScript engines. Consequently, you can run JavaScript on a browser. To run JavaScript on a browser,

  1. Open your favorite browser (here we will use Google Chrome).

2. Open the developer tools by right tapping on an empty area and select Inspect. Shortcut: F12.

3. On the developer tools, go to the console tab. Then, write JavaScript code and press enter to run the code.


Using Node.js

Node is a back-end run-time environment for executing JavaScript code. To run JS using Node.js, follow these steps:

  1. Install the latest version of Node.js.
  2. Install an IDE/Text Editor like Visual Studio Code. In VS code, create a file > write JS code > save it with .js extension.

3. Open up the terminal/command prompt > navigate to the file location > type node hello.js > hit enter.

4. You will get output on the terminal.


Note: It is likewise conceivable to run JavaScript on the terminal/command prompt straightforwardly. For that, essentially type node and press enter. At that point, you can begin writing JS code.


Creating Web Pages

JavaScript was at first made to make website pages intuitive, that is the reason JavaScript and HTML go inseparably. To run JS from a webpage, follow these steps:

  1. Open VS Code > Go to File > New File > Save it with .html extension. For example, main.html.
  2. Copy this doctype (minimum valid HTML code) and save it in the file.
<!doctype html>

<html lang="en">
<head>
  <meta charset="utf-8">

  <title>worldofitech</title>
</head>

<body>
  <script src=""></script>
</body>
</html>

3. Similarly create a JS file, write the following JS code and save it with .js extension like main.js.

console.log('hello world');

4. From inside the HTML file, we need to connect the main.js file to use it. You can accomplish that by adding the accompanying code in main.html.

<script scr="main.js"></script>

5. Open the main.html file using a browser.
6. To check if our JS code ran or not, Right-click on the web page > Inspect > Choose console tab.

Since you realize how to run JavaScript, we should begin taking in the basics of JavaScript from the next tutorial.


Thanks for reading! We hope you found this tutorial helpful and we would love to hear your feedback in the Comments section below. And show us what you’ve learned by sharing your photos and creative projects with us.