In ES6 two keywords in addition to var when declaring variables, i.e. let and const. Before ES6, the only way to declare a variable was through the var keyword.


const defines a constant reference to a value. This means the reference cannot be changed. You cannot reassign a new value to it.

e.g. you cannot do this as TypeError comes

const a = 0;
a = 5;

Executing the above lines of code in terminal, we will get an error as:
Uncaught TypeError: Assignment to constant variable.

const variables must be initialized at the declaration time.

If the data…

Dheeraj Prajapati

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