Loading, please wait...

Data Types

JavaScript Data Types

In JavaScript Data Types, the term datatype mainly refer to the different types of values with which a program can work.

JavaScript Variables can work with three primitive data types, such as numbers, strings, boolean and further non-primitive data types are objects, date, arrays.

 

For executing a program, it is important to know a data type of variables because without data type it is quite impossible for a computer to produce the output of a program.

Unlike any other programming language, JavaScript does not define different type of numbers, like integers, short, long, floating-point, etc.

 

Primitive Data Types

 

Data Type

Description

Number

represents the collection of characters e.g. “Welcome”

String

represents the numerical values e.g. 100

Boolean

represents the Boolean values either true or false

Null

represents the null value

undefined

represents the undefined value

 

 

For example,

var x = 10;                       //number             
var str = “TutorialLink” ;        //string      
var name = [ “Nitin”, ”Pandit” ];  //array   

Here, the variable x is a number data type as it assigns a value of 10. The variable str is a string data type as it assigns a value in a sequence of characters as “TutorialsLink”. The variable name defined as an array data type.