There are 2 types of data types in javascript.
Primitive datatype.
Reference datatype.
Let's talk about primitive datatypes first.
The predefined data types provided by JavaScript language are known as primitive data types. Primitive data types are also known as in-built data types.
The main features of a primitive data type are:
It is not an object (a collection of keys and values)
It does not have its methods (property of an object which is a function)
It is immutable (it cannot be changed and is read-only).
Primitive datatypes:
Number.
String.
Boolean.
Undefined.
Null.
Array.
Symbol.
Number:
Any magnitude of numbers can be stored using number datatype in javascript.
String:
A string is a sequence of characters or it can be a single character that represents text. A string can be created using single or double quotes.
Boolean:
The boolean data type has only two values, true and false. In some places when we check a condition or the existence of a variable or a value, true and false implies a ‘yes’ for ‘true’ and a ‘no’ for ‘false.
Undefined:
If the variable is not defined with any value then the type and value of that variable will be considered an undefined type.
Null:
If a variable is defined with a null value then the value of that variable will be null and the type will be an object.
Array:
An array is a collection of multiple items. You can store different types in an array.
Symbol:
The JavaScript ES6 introduced a new primitive data type called a symbol. Symbols are immutable (cannot be changed) and are unique. Though the value of a and value of b both contain the same description, they are different.