<p>The variables a,b , and c are assigned the values 50, 60, and 110:</p>
var a = 50; // var is a keyword which is used to define a variale
var b = 60;
var c = a+ b;
document.getElementById("example").innerHTML = c; // c is the result of a and b which gives 110. </script>
Fixed values are also known as literals.
The necessary rules for writing fixed values are:
Numbers can be written with or without decimals.for example:
Strings are text, written within single quotes or double quotes:
In any programming language, variables are used to store record.
to declare variables.
An equal sign is used to assign data to variables.
In this below example, a is a variable. Then, a is assigned the value 6:
to assign record to variables:
var a = 5;
var b = 6;
document.getElementById("example ").innerHTML = a + b;
to calculate values:
document.getElementById("example").innerHTML = (5 + 6) * 10;
An expression is a combination of variables, values, and operators, which
calculate the records.
The process called an evaluation. Following is an example:
document.getElementById("demo").innerHTML = 50 * 110;
The var keyword is used to create a new variable:
var a = 50 + 60;
var b = a * 110;
document.getElementById("example").innerHTML = b;
Code written after double slashes // or code between /* and */ is treated as
These comments are ignored, and will not be executed:
name, are two different variables.
Data types one of the most important characteristics of a programming
language. These are the type of data which is used to represent and
manipulate in a programming language.
There are three types of data types in JavaScrip −
- Numbers, eg. 2123, 1220.250 etc.
- Boolean e.g. true or false.
type known as object. We will discuss objects in detail in next article.