Sign in

Exploring let, const and var

With the arrival of ES5, JavaScript introduced two new ways to declare a variable, let and const. I prefer both these declarations over var because they remove some odd behaviors of var and also offer more meaning to our code. Let's take a look at some of the major differences between these statements.

var

The var statement declares a function-scoped, or globally-scoped variable. In…