Primitive Data Types :
Primitive data types in JavaScript include:
- Numbers - Integers, floats
- Strings - Any data under single quote, double quote or backtick quote
- Booleans - true or false value
- Null - empty value or no value
- Undefined - a declared variable without a value
- Symbol - A unique value that can be generated by Symbol constructor
Examples :
//numbers
let number = 10;
//strings
let name = "Manthan";
//boolean
let value = true/false;
//null
let value = null;
//undefined
let name;
//symbol
let a = Symbol();
Non Primitive Data Types
Non-primitive data types in JavaScript includes:
- Objects
- Arrays
Examples :
//object
let name = {firstName:"Manthan", lastName:"Ank"};
//array
let array = ["value1", "value2"]
//regExp
let pattern = /w3schools/i;