Difference Between Var , Let and Const ?

1 min read
Var: The scope of the variable defined with the keyword var is limited to the function within which it is defined . If it defined outside a function , the scope of the variable is global
Default value of var is undefined
Let : The scope of the variable defined with the keyword let is Limited to the Block defined by curly braces .
Default value of let is uninitialized
const: The scope of the variable defined with the keyword const is limited by the Curly braces block . However if a variable is defined with the keyword const it cannot be reassigned
Default value of const is uninitialized
1
Subscribe to my newsletter
Read articles from Anish sharma directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
