JavaScript data Types.

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

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”

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store