Variable Types - Javascript

What is a variable?
What are the variable types supported by javascript?


Variables are used to store values.
i.e. for example if we have to add two numbers, we will declare two variables and assign the numbers to each variable and add them to get the result.
var a = 5;
var b= 5;
var c = a+b;
Javascript can handle the following variable types
a) Number (Integer and Float)
b) String
c) Boolean
d) Null
e) Undefined

In javascript all variable types are declared as var, only depending on how we assign the values the data type is defined.
var a = "as"; --> This is a string type variable
var a = 2; --> This is a integer type variable
var a = true; --> This is a boolean type variable
Here var defines it as a variable.
"a" is the variable name.
"as", 2, true are called values.
The variable name can have alphanumeric values. Any lowercase (a-z) or uppercase (A-Z) alphabets, numbers (0-9) or underscore(_).

Ask Questions

Ask Question