Using Variables and Operators in JavaScript

In JavaScript, data can be temporarily stored in variables, which are named locations in memories. A variable has a name, value and a location in memory. The name of the variable, uniquely identifies the variable, the value refers to the data stored in the variable and the location refers to the memory address of the variable.

SYNTAX: The syntax to declare a variable in JavaScript is:

  1. var variableName;  

Where, var is a keyword.

Operators are used to manipulate the value of the variables.

Example: you have declared two variables marksMaths and marksScience and you want to compute the sum. So you have to manipulate the values and so for that you need Operators.

Definition: An operator is a symbol or a word reserved for a special task or action.

Demo

  1. Let’s create a document called UsingVariableAndOperators.html



  2. Write the code in the body tag.



  3. Execute the script by Opening the file in the Web Browser. If you are using Internet Explore click on “Allow Blocked Content” to allow the script to execute and you are using Mozilla Firefox then click on allow “ActiveX Controls”.

Thank you for reading this article.

Ebook Download
View all
Learn
View all