Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. Scope is the rules that define which part of the code can access which variables. The scope includes global scope which are variables that can be accessed by any part of the code, and block scope which are variables set as part of a function. Global scope variables are not only accessible by any part of the code but are persistently available. While block scope variables are no longer defined once a function completes.
  2. Global variables are generally avoided because they can cause indeterminate functions and make code hard to debug. Since the global variable can be accessed by any function in the code it can cause unintended side effects as well as making collaboration much more difficult.
  3. JavaScipt strict mode is used to eliminate global variables. If a global variable is found when running code it will throw an error instead of allowing the variable.
  4. Side effects are when code changes variables outside of their scope. Since most of the time these are unintended it can cause indeterminate functions. A pure function is one that is determinate and has no side effects whether intended or unintended.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement