JavaScript different between let, const and var

Benny Kang
Jul 7, 2021

--

let and const were introduced in ES6 modern JavaScript and var is old way

let is mutate variable so that value in a let variable can be changed. perfect use case of let is :

const - value in a const variable cannot be changed (cannot be mutated) and also, it cannot declare ‘empty’ const variables.

value changes with const
value in a variable cannot be changed
cannot declare ‘empty’ const variables

var - should actually be completely avoided. This is old way of defining variables prior to ES6 and it works pretty much same as let

--

--

No responses yet