Data Types in JavaScript

The blog describes the usage of JavaScript Data Types. Data Types are provided to store the different types of values to be used in the program.

JavaScript Data Types

The Data Types in JavaScript can be classified into 2 types:

  • Primitive JavaScript Data Type
  • Non-Primitive JavaScript Data Type (also called as Reference Data Types)

Primitive JavaScript Data Types

The Primitive JavaScript Data Type can be further classified as given below

Data TypeDescription
Stringstores string values
Numberstores numeric values
Booleanstores boolean values (true /false)
Undefinedstores undefined value
Nullstores NULL value

Non-Primitive JavaScript Data Types

The Non-Primitive JavaScript Data Type can be further classified as given below

Data TypeDescription
Objectstores an object
Arraystores group of similar values as an Array
RegExpstores regular expression value
var num1;   // represents an undefined variable 
num1 = 10;  // represents a variable with numeric value   
num1 = 20;  // reassignment of variable value 

(num1 == num2)  //returns false 

num1 ="Some Text";  // variable num1 now represents a String Value "Some Text"

num2 = "Added With" // variable represents a String Value "Added With" 

num3 = num1 + 40   // Variable represents a string value "Some Text40"

num4 = num2 + num3  // Variable represents a string value "Added With Some Text40"