Data Types in Javascript

When and how to use data types will give you a good comfort while you are writing your Javascript program, actually it counts for all programming languages on earth.

Boolean

Boolean data type has only two possible values: true and false.

Eg:

var honest = true; var honest = false;

Number

Number is an integer value used to create some numerical calculation.

Eg

var n = 0; var n = 9;

String

String or text values stored in a JS variable are type of String.

Eg

var honest = “I am honest!”; var honest = “1234567890”;

Arrays

An array holds multiple values in a single variable.

Eg

var male = [“wife”, “car”, “huis”, “dog”, “1000000”];

Objects

Objects are a blueprint of real life object and they may contain properties and behavior.

Eg

var person = {work:”Developer”, skills:”JS”, money:”00″, kind:”monkey”}

summary

Data types in JS are dynamic, a number type could be used as string type. The var keyword is a reserved keyword which is used to define variables in a JS program. Every variable in the JS is an object and everything is an object. Javascript is object oriented web programing language.