Using Data Types in Javascript Tutorial 3
Using Data Types in Javascript Tutorial 3
String
You need to use string in double quotation. Here is an example of string
myVariable = "Khan"Number
No use of double quotes. Otherwise it will considered as string. Write number or decimal number without double or single quotes.
myVariable = 420
Boolean
Boolean has only two crew members. True and False. In simple words Boolean is either true or fasle.
myVariable = true
myVariable = false
Always write Boolean without double or single quotes.
Array
Array is collection of variables. You can access each member easily.
var myArrayName = [1,'khan',343,"54",343]
How to access elements of array?
myArrayName[0];
Object
A standalone entity, with properties and type. But in simple words it is a custom variable which more than one members.
var person={first_name:"khan", last_name:"babo" age:22, single:true}
Null
Null is a special value. It shows an empty or unknown value
var person = null
Undefined
If you don’t assign a value to a variable and print it. It will print out as null
var person
Infinity
Infinity represent the concept of an infinit number
var person = 32/0
32 divided by zero is inifinity.