JavaScript Types of Value
As in Mathematics, you need 2 type of Values i.e. Constant and Variables. to do Operations
Same as in Javascript, you have to use 2 type of Values :
- Constant or Fixed Number these are called as Literals
- Variables.
Javascript Literals
There can be 2 Types of Values that can be termed as Literals.
- Numbers :
- Any Numeric Number can be considered as Literals.
- Example : 10, 20.5, 500 , 999.79
- Strings :
- Strings are Same as Text.
- Example : "Javascript" , "World of Programming".
To Write a String, you have to write it within double or single quotes.
Javascript Variables
Same as in Mathematics, Variables are used here to Store values.
In Javascript to Declare a Variable, you have to use a Keyword var .To Store Values in Variables equal sign (=) is used.
For Example :
var x;
x=10;
var y;
y=20.5;
var z;
z=999.79
Here,
10 is stored in x, 20.5 is stored in y and 999.79 is stored in z.
In Variables, you can store All Literals(numbers and string)
For Example :
var x;
x=10;
var y;
y = "Hello World"
Here, the Literal "Hello World" is stored in variable y.
In Later Section, We will got deep into Variables.