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
  • 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”

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to force CF 7 to load its javaScript and stylesheet only on the pages you need to.

No Need Of Null Checks Anymore In Typescript

17 React JS Tools For Developers

Sleek and interactive scroll bar using Angular directive

Different types of Forms

A blog on Binary Search Algorithm

Why and where you should use Node.js

How to learn ReactJS for 2019

Image result for react js 2019

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
Afroza Akter Ruma

Afroza Akter Ruma

More from Medium

JavaScript is Asynchronous or Synchronous?

JavaScript Array Methods — Iteration

JavaScript — Iteration Methods

Arrow Functions in JavaScript, How is it different?

Intro to Javascript Event KeyCodes