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 Type | Description |
---|---|
String | stores string values |
Number | stores numeric values |
Boolean | stores boolean values (true /false) |
Undefined | stores undefined value |
Null | stores NULL value |
Non-Primitive JavaScript Data Types
The Non-Primitive JavaScript Data Type can be further classified as given below
Data Type | Description |
---|---|
Object | stores an object |
Array | stores group of similar values as an Array |
RegExp | stores 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"