Learn JavaScript Variables In One Video! Learn JavaScript Variable Var, Let, and Const.

preview_player
Показать описание
Learn JavaScript Variables In One Video! Learn JavaScript Variable Var, Let, and Const.
Variable Keywords:
var :
var x; //declaration
x = 10; // assignment
var y =20; // initialization

1. function scope. : you can declare variable using var anywhere in function
and access it from anywhere
2. it allows shadowing : re-declaring or re- initialization but not assignment.
var x;
x = 10;
var x =20;
3. it support hoisting. it tells the interpreter that i am here.

Let
: it defines the block. it will work in closure.
it doesnt support hoisting
it also dont support shadowing
it support declaration, assignment and initialization.

Const : it also defines block scope
it will not allow hoisting and shadowing.
it will allow declaring and assignment.
it supports only initialization.
Рекомендации по теме
visit shbcf.ru