Types Of Datatypes in Javascript


Primitive
Primitive datatypes includes:
Number: For storing any numeric values
const score = 100;
Boolean: For storing any value in form of true and false
const isExist = true;
String: For storing any strings
const stringName = "Any string value";
Null:
const anyNullValue = null;
Undefined
const anyUndefinedValue = undefined;
Symbol : This is used for making unique identifiers. For example, if you want to make a use of id so there you can use symbol.
Example 1 : To Create Unique Object Keys
```javascript jsCopyEditconst id = Symbol("id"); const user = {
name: "Neel" };
**Example 2: To Create Private Object Properties (pseudo-private)**
```javascript
jsCopyEditconst privateProp = Symbol("secret");
const obj = {
[privateProp]: "hidden value"
};
BigInt
const anyBigIntValue = BigInt("1233737373838383838383");
Non Primitive/ Reference
Arrays: For storing values in contiguous memory locations
const arrays = [1, "any string value", false]
Objects: For storing multiple/different values in form of key-value pairs
const anyObj = { key_1 : "string", key_2 : 2, key_3 : false }
Functions: For executing operations
const anyFunction = function(){ console.log("Hello, beautiful Mountains"); }
Subscribe to my newsletter
Read articles from Neelesh Joshi directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Neelesh Joshi
Neelesh Joshi
Hi, am a passionate programmer and front-end web developer I am interested in problem solving