Differences Between Var, Let, and Const



var

global scope
can be reassigned
allows hoisting

let

block scope
cannot be reassigned
does not hoist
let allows us to change the values, eg. it is used inside loop.


const

block scope
cannot be reassigned
does not hoist
- we cannot change const or reassign variable, but const allows you to change the properties of an object, if it is an object.
- const only allows changing the values of its properties, but does not allow to re-declaring the variable.
- recommend to use const





-


Comments