Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. What is scope? Your explanation should include the idea of global vs. local scope.
  2. Scope is what kind of access Javascript has to a variable. Global variables are accessable to the entire window object,
  3. and local variables are only accessible to the objects or functions the variable is in.
  4.  
  5. Why are global variables avoided?
  6. Global variables are generally avoided because with large programs it would be difficult to manage all the unique global variables
  7. that would be created, and unintended side effects could result. It could also cause functions that you would like to be determinate
  8. to become indeterminate.
  9.  
  10. Explain JavaScript's strict mode
  11. Strict mode is something you can enable where Javascript will give you an error anytime you declare a variable without the "var" keyword.
  12. It is good practice to include this in all your Javascript files.
  13.  
  14. What are side effects, and what is a pure function?
  15. Side effects are the unintended consequences of creating a global variable. A pure function means that there aren't any side effects and
  16. each function is determinate.
  17.  
  18. Explain variable hoisting in JavaScript.
  19. Hoisting is when a variable inside a function is elevated into the global scope. Usually this isn't desired, but in some circumstances it
  20. is needed.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement