Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. Variable scope determines whether if a variable is accessible or not throughout the code, script. When using let or const to
  2. declare a varible, there are two kinds of scope: global and block. Global scope variable can be accessed from anywhere in the code
  3. or even different files while block scope variable can only be accessed inside the function's block code. In short, we should avoid
  4. declaring global variables at all most of the time because it will be likely to create unintended side effects and make the code
  5. become indeterminate.
  6.  
  7. Javescript's strict mode basically prevent us from altering global varibles'(if there is any) value inside a function by indicating
  8. 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
  9. 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
  10. effects and always return the same value with the same inputs/test values.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement