Guest User

Untitled

a guest
May 28th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. What is scope? Your explanation should include the idea of global vs. local scope.
  2. Why are global variables avoided?
  3. Explain JavaScript's strict mode
  4. What are side effects, and what is a pure function?
  5.  
  6.  
  7. 1.Scope is used to avoid bugs and to be able to collaborate easier. It is a set of rules that defines how
  8. the variables in your code can be accessed. Global scope can be accessed across files and is more likely to
  9. have side effects which leds to bugs. Local scope takes precedence over global scope using the scope chain which begins
  10. with the local varibales.
  11. 2. Global variabes should be avoided because it makes it harder to find bugs in your code as well as harder to collaborate
  12. with others. It can also extend across your files which could alter values of variables.
  13. 3. JavaScript strict mode makes chnges to the normal JS semantics. It eliminates some JS silent errors, fixes mistakes and
  14. prohibits some syntax. It does not apply to block statments in curly brackets.
  15. 4. Side effects are whe a variable reaches outside its local scope into the parent scop and alters the value. Pure function
  16. means that it is determinate and has no side effects. (Determinate means that it returns same value)
Add Comment
Please, Sign In to add comment