# JavaScript Errors - Throw and Try to Catch
Hoisting is JSP's default behavior of moving declarations to the top.
● JavaScript Declarations are Hoisted
In JavaScript, a variable can be declared after it has been used.
In other words, a variable can be used before it has been declared.
Hoisting is JavaScript's default behavior of moving all declarations to the top of the current scope.
In other words, a variable can be used before it has been declared.
Hoisting is JavaScript's default behavior of moving all declarations to the top of the current scope.
● JavaScript Initializations are Not Hoisted
JavaScript only hoists declarations, not initializations.
below two examples are similar, But result is different.
This because only the declaration ( var y), not the initialization (=7) is hoisted to the top.
Because of hoisting, y has been declared before it is used, but because initializations are not hoisted, the value of y is undefined.
below two examples are similar, But result is different.
This because only the declaration ( var y), not the initialization (=7) is hoisted to the top.
Because of hoisting, y has been declared before it is used, but because initializations are not hoisted, the value of y is undefined.
No comments:
Post a Comment