Guest User

Untitled

a guest
Oct 18th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. What is scope?
  2. Refers to the current context of the code which could be either 'global' or 'local'. When one first starts a Javascript
  3. code it is in the global scope. Declared variables here are defined globally. The local scope lives inside of functions
  4. and each function, included nested functions, have their own local scope; however, any function defined within other
  5. functions will have linked scopes - inner local scopes are linked outwardly.
  6.  
  7. Why are global variables aviod?
  8. Global variables can some code to be indeterminate (returns different values at times) which makes tracking down bugs
  9. difficult.
  10.  
  11. What is strict mode?
  12. A way to opt into a restrictive variant of JavaScript which has different semantics than normal JavaScript. It
  13. eliminates some sillent errors and changes them into throw errors. It also fixes mistakes that make it difficult for
  14. JavaScript engines to perform optimizations, and it prohibits syntax that will be defined in the future. The option is
  15. enacted by witing the command 'use strict;' at the top of the file for global control or at the top of a function for
  16. local control.
  17.  
  18. What are side effects, and what is a pure function?
  19. A side effect is when a functions is able to reach outside of its local scope to change values in other areas of
  20. the code. A function is "pure" when it is determinate (returns the same value consistently with the same set of inputs)
  21. and cuases no side effects in the proram overall.
Add Comment
Please, Sign In to add comment