You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ahmed Isam | Papula Ali | Dilan Ahmed | Muhammad Sabah | Ara Kardo.
it is a Global Scope.
The scope for Variable X in both Let and Var deceleration are global scope and the console log will bring the variables outside the {} blocks but there is a little detail here. the first console log will print the first let variable value which is 1 , for the VAR it will print 2 as the var is a global declared variable itself and can be re assigned . Also another thing here is, when you console log it it gives an Error as the same variable name is declared twice once by let and the other by var which causes the Error .
is a functional scope and will bring back 1.
4.It is called lexical scoping, also known as static scoping. In lexical scoping, the scope of a variable is determined by its position within the source code
The global scope can be accessed globally in the code, but the other type of scoping can only be accessed within the range of its scope .
let can not be re declared but can be re assigned. On the other hand Var is a global declared variable and can be re declared and re assigned.
a global scope is when we can access a variable everywhere in our program but in a local scope it can only be accessed within a specific scope and cant be accessed from the outside. we use global scope when we need to access a variable everywhere.
Ahmed Isam | Papula Ali | Dilan Ahmed | Muhammad Sabah | Ara Kardo.
it is a Global Scope.
The scope for Variable X in both Let and Var deceleration are global scope and the console log will bring the variables outside the {} blocks but there is a little detail here. the first console log will print the first let variable value which is 1 , for the VAR it will print 2 as the var is a global declared variable itself and can be re assigned . Also another thing here is, when you console log it it gives an Error as the same variable name is declared twice once by let and the other by var which causes the Error .
is a functional scope and will bring back 1.
4.It is called lexical scoping, also known as static scoping. In lexical scoping, the scope of a variable is determined by its position within the source code
The global scope can be accessed globally in the code, but the other type of scoping can only be accessed within the range of its scope .
let can not be re declared but can be re assigned. On the other hand Var is a global declared variable and can be re declared and re assigned.