By: Harshal Patil

JavaScript is a text-based programming language used both on the client-side and server-side that allows you to make web pages interactive. Where HTML and CSS are languages that give structure and style to web pages, JavaScript gives web pages interactive elements that engage a user.

Linking Js with HTML:

<html>
<head>
    <title>Document</title>
</head>
<body>
    <!-- linking app.js file -->
    <script src="app.js"></script>
</body>
</html>

Variables

What are variables:

JavaScript Variable is simply a name of storage location. There are two types of variables in JavaScript : local variable and global variable.

There are some rules while declaring a JavaScript variable (also known as identifiers).

  1. Name must start with a letter (a to z or A to Z), underscore( _ ), or dollar( $ ) sign.
  2. After first letter we can use digits (0 to 9), for example value1.
  3. JavaScript variables are case sensitive, for example x and X are different variables.

Defining Variables:

Untitled

In this example, these are variables, declared with the var and let keyword:

If you want a constant variable: always declare variables with const.