Learn JavaScript Programming

A scripting language that enables you to create dynamically updating content, control multimedia, animate images, and pretty much everything else.

JS Introduction
JS Control flow
JS Functions
JS Objects
JS Types
Exceptions and Modules
JS ES6
JavaScript Asynchronous
Miscellaneous

Ways to execute

In this tutorial, you will learn about different ways to run JavaScript on your computer.

JavaScript is a popular programming language that has a wide range of applications.
JavaScript was previously used mainly for making webpages interactive such as form validation, animation, etc. Nowadays, JavaScript is also used in many other areas such as server-side development, mobile app development and so on.

Because of its wide range of applications, you can run JavaScript in several ways:


1. Using Console Tab of Web Browsers

All the popular web browsers have built-in JavaScript engines. Hence, 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 clicking 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 Javascript 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 index.js ( name of your file ) > hit enter. or you can just press the shortcut in vs code Ctrl Alt N

  4. You will get the output on the terminal.


By Creating Web Pages

JavaScript was initially created to make web pages interactive, that's why JavaScript and HTML go hand in hand. To run JavaScript 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. Type this doctype (minimum valid HTML code) or you can also use code snippet in VS code just type ! then hit enter, give path of javascript file and save it in the file

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

  4. Open the index.html file using a browser.

  5. To check if our JS code ran or not, Right click on the web page > Inspect > Choose console tab.

Now that you know how to run JavaScript, let's start learning the fundamentals of JavaScript from the next tutorial.


Share this page on :