Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Variable scope determines whether if a variable is accessible or not throughout the code, script. When using let or const to
- declare a varible, there are two kinds of scope: global and block. Global scope variable can be accessed from anywhere in the code
- or even different files while block scope variable can only be accessed inside the function's block code. In short, we should avoid
- declaring global variables at all most of the time because it will be likely to create unintended side effects and make the code
- become indeterminate.
- Javescript's strict mode basically prevent us from altering global varibles'(if there is any) value inside a function by indicating
- an error when we try to declare a variable without let or const. Side effects are usually bad but can be a good thing. An example of
- a bad side effect would be unintendedly change of a global varible by using a function. A pure function does not have any bad side
- effects and always return the same value with the same inputs/test values.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement