filmov
tv
Var, Let, and Const in JavaScript for Beginners

Показать описание
In this video I talk about the key differences between var, let, and const in JS.
TL;DW
- var can be declared more than once while the others cannot
- var and let can be reassigned while const cannot - it's constant!
- let and const have block scope while var does not
- JS "hoists" variables declarations with var to the top of the document and does not do so with let and const
- Don't use var, use const for variables and if you know you may assign a different value to the variable in the future, use let
TL;DW
- var can be declared more than once while the others cannot
- var and let can be reassigned while const cannot - it's constant!
- let and const have block scope while var does not
- JS "hoists" variables declarations with var to the top of the document and does not do so with let and const
- Don't use var, use const for variables and if you know you may assign a different value to the variable in the future, use let