JavaScript is pretty easy to setup and the user can get started on writing his/her first lines of JS code in just minutes. There are a couple of ways you can run JavaScript code on your own computer. Some of them are listed down below.
How to run JavaScript on your computer 🤔
Below are some of the common ways you can execute JavaScript on your computer:
- Run JavaScript on the Browser
- Run JavaScript inside an HTML File
- Run JavaScript using Node.js
- Run JavaScript using an Online JS Editor
Note: Make sure to check out our 👉 JavaScript Introduction lesson.
Run JavaScript on the Browser 💻
You can execute JavaScript code on almost all the currently existing browsers. Here, we choose Google Chrome.
Step 1: Open a new tab in the browser, hover the mouse cursor anywhere on the screen and right click. A list of options open up and among those options, click on Inspect. [Note: You can also achieve the same thing if you press F12 after opening the new tab.]

Step 2: A dialog box opens up. That dialog box is called the Browser DevTools. As a web developer, you will be using that a lot. Among other tabs in the DevTools, click on Console. After you click on Console, a blank (sometimes not) editor like space appears where you can type anything.

Step 3: Let’s type some JavaScript code into it. Type: console.log(“Hello World”); and press enter. You will see “Hello World” appear on the console in the next line.
You may not understand the code right now, but no worries. The next lesson will teach you about the console.log command.

This is how you execute JavaScript just inside your Web Browser.
Run JavaScript inside an HTML File 👨💻
You can also execute JavaScript code by inserting it inside an HTML File. [Note: If you don’t know much about HTML, you can learn it on the internet. It’s pretty easy. Besides, one of these days, we might launch a free course on HTML 😎.]
Step 1: First you need to install a Text Editor of your choice. We suggest Visual Studio Code editor. Download it from here.
Step 2: Open Visual Studio Code, click on File in the top-left corner and select New File.
After creating a new file, save it and give it an extension of .html by going to File>Save the file. We named it test.html here.
Then, copy the code down below and save it again. You can use the shortcut Ctrl+s to save it.

Step 3: Create another file and save it. This time we will create a JavaScript file by giving the extension .js.
Name the file. We named it script.js here.
Then, copy the code down below and save it again. Don’t forget the shortcut Ctrl+s.

Step 4: It’s time to attach our script.js file into our test.html file. Edit the “test.html” file by putting the “script.js” file location in the src attribute of the script tag. Do according to the picture below.

Step 5: Now, open the HTML file by going into the file location and clicking on test.html. It will open in your browser (your Default Browser). Then, go to anywhere in the screen, right click and select Inspect. You can do the same using the shortcut F12. Then, click on the Console tab. There, you will see “Hello World” printed out.

This is how you execute JavaScript inside an HTML File.
Run JavaScript using Node.js 😎
Another popular way to run JavaScript on your computer is by using Node.js. Node.js is a runtime environment for JavaScript which lets you run JS code directly in a terminal that has Node.js installed on it. Many of the backend or server-side applications build in JavaScript were possible because of Node.js.
Step 1: First you need to install Node.js. Download it from here. Finish the installation.
Step 2: Create a JavaScript file on your desired location. Don’t forget to give the .js extension. And write the following code given below.

Step 3: Open the Terminal available on your operating system. Navigate to the location where you kept the JavaScript file. [Note: If you don’t know how to navigate to a file location using a Terminal, you can always learn it from the Internet.] Then, type the command: node filename.js and press enter.
Here, our file name is test.js, so the correct command would be: node test.js
Then, press enter.
You will see “Hello World” displayed on the Terminal Screen.
See the image below for clarity.

This is how you execute JavaScript using Node.js and a Terminal.
Run JavaScript using an Online JS Editor 🔗
If you want to start executing immediately without setting up, there are plenty of online JS editors on the web. Some of the popular ones are: