With the release of ES6, two new ways of variable declaration were introduced in JavaScript. These new ways use the keywords ‘let’ and ‘const’. These were basically improvements to the old way of declaring variables using ‘var’. To understand each of these 3 ways of declaring variables, we need to understand two important concepts in JavaScript — Scope and Hoisting. This will further give a better understanding as to why a new way of declaring variables was needed and also the various differences between var, let and const declaration.

Scope

In programming, scope of a variable implies where the variable can…

Sriharsh Aditya

Backend Developer and Linux Enthusiast

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