Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. What is scope? Your explanation should include the idea of global vs. local scope.
  2. Scope refers to where variables are defined. A global scope is where a variable is available through the entire Javascript file wheras
  3. local scope would be a variable that is defined and accessable only within a certain part of the file such as a function
  4.  
  5.  
  6. Why are global variables avoided?
  7. A global variable being available through a whole document can lead to that variable being altered in different ways throught the whole
  8. file making a function indeterminate (returns different values in certain areas using the same input) and will make tracking down a bug
  9. difficult as with the golbal scope it could be altered anywhere in the code.
  10.  
  11. Explain JavaScript's strict mode
  12. JavaScript strict mode is a mode you can enter at the top of your javascript file that will force global variables to return undefined
  13. value
  14.  
  15. What are side effects, and what is a pure function?
  16. Side effects are intended/unintended consequences of a function outside of the declared function itself. A pure function is one with no
  17. side effects and is a determinate function (always returning the same value when passed the same input).
  18.  
  19. Explain variable hoisting in JavaScript.
  20. Variable hoisting refers to the way JavaScript parses a file. Javascript will pass over the file looking for all variable declarations
  21. and then moves them to the top of their respective scope.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement