× Please, log in to give us a feedback. Click here to login

You must be logged to download. Click here to login


MrBool is totally free and you can help us to help the Developers Community around the world

Yes, I'd like to help the MrBool and the Developers Community before download

No, I'd like to download without make the donation


MrBool is totally free and you can help us to help the Developers Community around the world

Yes, I'd like to help the MrBool and the Developers Community before download

No, I'd like to download without make the donation

JavaScript Data Types

In this article we will discuss about different types of data in JavaScript. JavaScript is used widely in web development so its data types are very important. The developers should know it very well before they start web development.

A PC mechanism with principles. It manipulates principles and produces some kind of effect. Depending on the program, it may be incomplete as to what types of principles it can be able to effort with. The types of principles a program can effort with are acknowledged as its data types.

JavaScript ropes various types of information.

The JavaScript Data types Are ---1.String, 2. Number, 3. Boolean, 4. Array, 5.Object, 6. Null, 7. Undefined.

Data types: Date types can be classified into two broad categories, primitive and complex.

A primitive data type is a data type that provisions a solo price, usually a truthful of some kind, such as numbers and strings.

A composite data type, for the purposes of JavaScript, is the same obsession as a thing. It is a data type that can consist of many principles grouped jointly in some way. JavaScript treats substance as associative arrays. An associative array can be defined as an array that is able to have its rudiments linked with names in totalling to their numeric index place in the array.

JavaScript also treats functions as substance. These resources that functions be able to use in a minute similar to some former unpredictable.

  • String, Number & Boolean is the Primary (Primitive) data types.
  • Object & Array is the Composite data types.
  • Null & Undefined is the Special data types.

This is the JavaScript Data types. It is very necessary For JavaScript.

JavaScript Has Dynamic Types:

JavaScript has dynamic types. This means that the same uneven be able to be used as diverse types:


        var x;    // Now x is approximate (Undefined).
        var x = 6;   // Now x is a digit (Number).
        var x = "Ari";  // Now x is a cord (String).

The First JavaScript Data types are “String”.

JavaScript Strings:

A string is a changeable which stores a series of typescript like "Ari Das".

A string can be any text within speech marks. Single or double speech marks can be used as per our requirement:


var carname="Maruti Wd60";
var carname='Maruti Wd60';

You can use quotation marks surrounded by a string, as long as they don't competition the quotation marks nearby the string:


var answer="Aridam is a Good Boy";
var answer=' The boy going to school by bus';
var answer=' The boy going to school by bus';

Final Example:

Listing 1: Sample showing variables as var type, print the value of variable.

<!DOCTYPE html>

var carname1="Maruti Wd60";
var carname2='Maruti Wd60';
var answer1="Arindam is a Good Boy";
var answer2=' The boy going to school by bus';
var answer3=' The boy going to school by bus';

document.write(carname1 + "<br>")
document.write(carname2 + "<br>")
document.write(answer1 + "<br>")
document.write(answer2 + "<br>")
document.write(answer3 + "<br>")

I will study a lot extra about strings in the higher segment of this lesson.

The Second JavaScript Data types Are “Number”.

JavaScript Numbers:

JavaScript has merely one kind of numbers. Numbers can be able to written from beginning to end, or devoid of decimals:


var x1=56.00;      // with decimals
var x2=56;         // without decimals

Additional large or additional small numbers can be printed by technical (exponential) information:


var y=123e6;      // 123000000
var z=123e-6;     // 0.000123

Final Example:

Listing 2: Script of Number Data type in JavaScript

<!DOCTYPE html>
var x1=32.00;
var x2=32;
var y=123e6;
var z=123e-6;
document.write(x1 + "<br>")
document.write(x2 + "<br>")
document.write(y + "<br>")
document.write(z + "<br>")

I will describe about numbers in the superior segment of this lesson.

The Third JavaScript Data types are “Boolean”.

JavaScript Boolean:

Booleans be able to merely have two principles: 1) right & 2) fake.


var c=right;
var d=fake;

Booleans be frequently used in provisional testing. I will be trained more about provisional testing in an afterwards episode of this lesson.

The Fourth JavaScript Data types are “Array”.

JavaScript Arrays:

The next code generates an Array called cars:

var cars=fresh Array();

Or (compressed array):

 var cars=fresh Array ("Sumo","Maruti","Alto");

Or (factual array):

var cars=["Honda","VW","Vento"];

Final Example:

Listing 3: Script to demonstrate JavaScript Boolean Data Types

<!DOCTYPE html>
var i;
var cars = new Array();
cars[0] = "Sumo";
cars[1] = "Maruti";
cars[2] = "Alto";
for (i=0;i<cars.length;i++)
document.write(cars[i] + "<br>");

Array indexes be zero-based, which means the primary item is [0], next is [1], and consequently going on.

I will study a lot additional about arrays in afterwards chapters of this lesson.

The Fifth JavaScript Data types are “Object”.

JavaScript Objects:

An object is surrounded by wavy braces. Within the braces the substance properties are distinct as name and value pairs (name: value).

The properties are split by commas:

var persn={firstnm:"Ari", lastnm:"Das", id:4433};

The article (person) in the model above has 3 properties: firstname, lastname, and id.

Spaces and line breaks are not significant. Your statement can distance numerous lines:

                   var persn={
                   firstname : "Ari",
                   lastname  : "Das",
                   id        :  4433

You can speak to the thing properties in two habits:



Listing 4: Script to display JavaScript Object Data Types

<! DOCTYPE html>
var person={
firstname : "Ari",
lastname  : "Das",
id        :  4433
document.write(person.lastname + "<br>");
document.write(person["lastname"] + "<br>");

I will be trained a lot additional about substance in later chapters of this lesson.

The Sixth and Seventh JavaScript Data types are “Null” and “Undefined”.

Undefined is the assessment of a changeable with no value.

Variables can be emptied by location the value to Null;



Listing 5: Java script has two more literals; Null and Undefined.

<! DOCTYPE html>
var person;
var car="Maruti";
document.write(person + "<br>");
document.write(car + "<br>");
var car=null
document.write(car + "<br>");

Declaring Erratic as a Thing:

When an erratic is affirmed with the keyword "new", the erratic is affirmed as a thing:

                 var name = new cord (string);
                 var x =    new digit (Number);
                 var y =    new Boolean;

Data Types:

JavaScript variables have an identifier, scope, and a specific data type.

Variables in JavaScript are a large amount like those in any other words; you use them to hold principles in such a way that the principles can be clearly accessed in special spaces in the code. Each has an identifier that is exceptional to the capacity of use (more on this later), consisting of any amalgamation of letters, digits, underscores, and dollar signs. An identifier doesn’t have a necessary layout, other than it must start with a quality, dollar sign, or underline:

  • _variableidentifier
  • __variableidentifier
  • variableIdentifier
  • $variable_identifier
  • Var-ident

Opening with JavaScript 1.5, you can also use Unicode letters and digits, as well as break out sequences (such as \u0009). The subsequent are also valid erratic identifiers for JavaScript: T\u0009

Use particular characters with concern, while, as some tackle such as debuggers may have complexity with them.

JavaScript is case-sensitive, which means it treats upper- and lowercase characters in a different way For example, JavaScript sees the subsequent two changeable identifiers as divide variables:

  • stringVariable
  • stringvariable

A supplementary restraint on changeable identifiers is that they can’t be a JavaScript keyword, in other keywords may be additional over occasion, as new versions of JavaScript (well, technically, ECMAScript) are unconfined. Naming strategy separately from the variable identification limitations enclosed in the earlier segment, you can use any identifier for variables and functions within code, but a number of designation practices-many innate from Java and other programming languages-can make the code easier to pursue and preserve.

First, use significant words somewhat than somewhat you’ve terrified jointly rapidly. For example, the changeable identifier interestRate is more evocative than the changeable intRt or even ir. The last two names are too mysterious and too tricky to appreciate, even within a given background.

You can also present a data type sign as part of the name, using somewhat such as the subsequent, which is a cord, investment a first name:

var strFirstName = "Shelley";

This type of naming gathering-using the data type as part of the changeable name-is known as Hungarian notation, and is particularly accepted in Windows development. As such, you’ll most possible see it used within the older JScript applications formed for Internet Explorer, but less often in more contemporary JavaScript development.

Another designation conference is to use a plural for collections of matter:

var customerNames = new Array ();

Characteristically, variables are not capitalized since capitalization is typically retained for items such as String:

var firstName = String("Shelley");

Reserving capitalization for substance makes them easier to distinguish from uncomplicated variables.

Functions and variables recurrently start with lowercase letters, and fit in a verb demonstrating what the purpose is doing. Its attractive simple to deduction what the next purpose is undertaking:

function validateNameInRegister(firstName,lastName)

A lot of times, variables and functions have one or more words concatenated into a exclusive identifier, subsequent a set-up popularized in other languages and regularly referred to as Camel Case as of the up-down scenery of the name, like a camel’s humps:


The Camel Case designation set-up makes the variable much more legible, although dashes or underscores among the variable “words” work as well:


The newer JavaScript libraries widely use Camel Case memo, which I also favour for my own applications.

However you can utilize a number, dollar sign or underscore to start on a variable, your best bet is to start with a letter.

Preventable use of unforeseen font in variable names can make the code harder to read and follow, particularly for newer JavaScript developers. Though, if you’ve looked at a number of the newer JavaScript libraries plus examples, you force contain noticed a number of odd-looking variable names. The trendy Ajax-based Prototype JavaScript library is a tough pressure in this observe-so much so that I think of the increase of new naming conventions as the “Prototype effect.”

The subsequent is a case of this result:

var _break = someval;

The underline is used in these libraries to sign a variable that’s an object’s confidential data associate. An additional attractive christening difference that Prototype has introduced is the following, which uses the dollar sign ($) to name an occupation that precedes an orientation to a page constituent:


The use of the underline or dollar sign doesn’t modify the performance of the variable, even although such custom is comparatively new. It’s just an extra way of naming something.


This lesson covered the indispensable awareness connected to data types in JavaScript. This province is very minor road, so I recommend that go all the way through the rudiments and then endeavour for some precede functionality. Communicative what data type your variables are very important. We’ll be by income of all the data types in this lesson succession. There are in fact more data types such as arrays and substance, but persons are a bit go on. We will be discussing what individuals are and how to use them in probable classes. If you don’t fully understand how to use these data types, then don’t be anxious. We’ll be practicing with them a lot and you will distinguish their grounds in our programs.

Website: www.techalpine.com Have 16 years of experience as a technical architect and software consultant in enterprise application and product development. Have interest in new technology and innovation area along with technical...

What did you think of this post?
To have full access to this post (or download the associated files) you must have MrBool Credits.

  See the prices for this post in Mr.Bool Credits System below:

Individually – in this case the price for this post is US$ 0,00 (Buy it now)
in this case you will buy only this video by paying the full price with no discount.

Package of 10 credits - in this case the price for this post is US$ 0,00
This subscription is ideal if you want to download few videos. In this plan you will receive a discount of 50% in each video. Subscribe for this package!

Package of 50 credits – in this case the price for this post is US$ 0,00
This subscription is ideal if you want to download several videos. In this plan you will receive a discount of 83% in each video. Subscribe for this package!

> More info about MrBool Credits
You must be logged to download.

Click here to login