JavaScript data Types.

Afroza Akter Ruma
2 min readMay 6, 2021

--

The main JavaScript data types can be divided into two parts:

One is primitive types and One is reference types.

There are primitive types

  • String
  • Number
  • Boolean
  • Undefined
  • Null
  • Symbol

Symbol:

Symbol Es6 has been added to the premitives

examples:

let customerName = ‘Jhon Doe’; // string literal

let firstName = String (‘Jhon’); // factory function

let lastName = new String (‘Doe’); // constructor function

let price = 24.45; // Number Literal

let unit = 3; // Number Literal

let isNewCustomer = false; // Boolean Literal

let discount = null;

Checking a Type:

String:

let customerName = ‘Jhon Doe’; // string literal

typeof customerName; // “string”

let firstName = String (‘Jhon’); // factory function

typeof firstName; // “string”

Object:

let lastName = new String (‘Doe’); // constructor function

typeof lastName; // “object”

Number:

let price = 24.45; // Number Literal

let unit = 3; // Number Literal

Boolean:

let customerName = ‘Jhon Doe’; // string literal

let price = 24.45; // Number Literal

let unit = 3; // Number Literal

let isNewCustomer = false; // Boolean Literal

let discount = null;

typeof isNewCustomer; // “boolean”

Null:

let discount = null;

typeof discount; // ”object”

Undefined:

let customerName = ‘Jhon Doe’; // string literal

let price = 24.45; // Number Literal

let unit = 3; // Number Literal

let isNewCustomer = false; // Boolean Literal

let discount = null;

typeof firstName; // “undefined”

--

--