DEV Community

Manthan Ankolekar
Manthan Ankolekar

Posted on

Data types in JavaScript

Primitive Data Types :

Primitive data types in JavaScript include:

  1. Numbers - Integers, floats
  2. Strings - Any data under single quote, double quote or backtick quote
  3. Booleans - true or false value
  4. Null - empty value or no value
  5. Undefined - a declared variable without a value
  6. 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();

Enter fullscreen mode Exit fullscreen mode

Non Primitive Data Types

Non-primitive data types in JavaScript includes:

  1. Objects
  2. Arrays

Examples :

//object
let name = {firstName:"Manthan", lastName:"Ank"};

//array
let array = ["value1", "value2"]

//regExp
let pattern = /w3schools/i;
Enter fullscreen mode Exit fullscreen mode

Top comments (0)