Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. 1) The term scope refers to the visibility of variables in one's code. Scope determines whether or not a variable is read.
  2. Global variables are variables defined outside of a function. Block variables are defined locally inside of a function.
  3.  
  4. 2) Global variables are avoided because they causes unintended side effects - such as unintentionally altering a value. This causes a code to become indeterminate -- returning inconsistent vaules.
  5.  
  6. 3) A way to combat global variables is by using JavaScript's 'strict mode'.Strict mode requires variables to be delared with either 'let' or 'const' otherwise an 'Uncaught Reference Error' will be triggered. This helps to not create global variables.
  7.  
  8. 4) Side effects occur when you unintentionally mutate a global variable. A pure function is code that is determinate (has the same output every time) and has no side effects.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement