Guest User

Untitled

a guest
Jul 12th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. What is scope? Your explanation should include the idea of global vs. local scope.
  2.  
  3. Global scope is when a variable you define is outside of a function and is available to access anywhere in your code.
  4. While block scope is a variable defined inside of a function and disapears afterwards.
  5.  
  6.  
  7. Why are global variables avoided?
  8.  
  9. We avoid globals so that a variable inside of block scope does not reach into its parent scope and alter another variable
  10. (aka side effects).
  11.  
  12. Explain JavaScript's strict mode.
  13.  
  14. Once strict mode is enabled (by placing 'use strict' at the top of the file (or inside of a function if that situation was
  15. necessary) makes sure that variables are not defined with out let or const. (aka something = 'something else'). If we try
  16. to define variables while in strict mode it will raise an uncaught reference error.
  17.  
  18. What are side effects, and what is a pure function?
  19. A side effect is when a funtcion reaches outside of its local scope into its parent scope and alters a value there.
  20. A pure function is one that does not have any side effects and that is also determinate (having the same value given the same inputs).
Add Comment
Please, Sign In to add comment