In JavaScript, you can assign different types of values to a variable e.g. string, number, boolean, etc. JavaScript provides different data types to hold different types of values.
There are two types of data types in JavaScript.
JavaScript Dynamic type Language
JavaScript is a dynamic type language, means you don't need to specify type of the variable because it is dynamically used by JavaScript engine. You need to use var here to specify the data type. It can hold any type of values such as numbers, strings etc.
Example
var a=30;//holding number1. JavaScript primitive data types
The followings are primitive data types in JavaScript.
Data Type | Description |
---|---|
String | It represents sequence of characters e.g. "hello" |
Number | It represents numeric values e.g. 100 |
BigInt | It is a numeric value in the arbitrary precision format. e.g. 453889879865131n, 200n, etc. |
Boolean | It represents boolean value either false or true |
Undefined | It represents undefined value |
Null | It represents null i.e. no value at all |
2. JavaScript Non-primitive data types
The structural data types contain some kind of structure with primitive data.
Data Type | Description |
---|---|
Object | An object holds multiple values in terms of properties and methods. Example
|
Date | The Date object represents date & time including days, months, years, hours, minutes, seconds, and milliseconds.
Example
|
Array | An array stores multiple values using special syntax.
Example |