Scope
Where can i access my variable in my code(where is the variable in my code).
Function Scope:
Every Execution context has a link with the outer environment or link with its parent environment.
we can access the parent variables from any of its child, but not from parent to child.
Note: As mentioned in the optimized code topic not to use eval() and with in JavaScript, it may confuse the JavaScript engine regarding the scope while optimizing the code, some times it may de-optimize the code.
Block Scope:
A variable created inside a curly braces "{ }", cannot be accessible outside.
Block scope is introduced in JavaScript as ES6.
variables should be declared with "let" or "const" key word.
Function VS Block Scope:
Last updated