Guest User

Untitled

a guest
May 23rd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. What is scope? Your explanation should include the idea of global vs. local scope.
  2.  
  3. A scope is where a variable can and can not be accessed. For example, variables in a global scope can be accessed anywhere on the
  4. page and are not restricted to a function. On the other hand, a variable from local scope can only be assesed within the funtion that
  5. it is contained in. This can prevent errors or unintended results because variables can only be used within it's function.
  6.  
  7.  
  8. Why are global variables avoided?
  9.  
  10. Global variables area avoided due to the fact that they can be accessesd anywhere on a page, and even across differet files. This can cause
  11. unintended mistakes to happen as you may call a global variable when you were not intending on doing so.
  12.  
  13.  
  14. Explain JavaScript's strict mode
  15.  
  16. JavaScript's script mode is when you place the string 'use strict' before wrting a line of code. This causes a varible to must be declared
  17. using const or let. If a variable is not declared using let or const, then an error will occur.
  18.  
  19.  
  20. What are side effects, and what is a pure function?
  21.  
  22. Side effects are when a function moves out of its local scope and changes a global scope variable. A pure function is when a function
  23. does what it is supposed to do and has no side effects.
Add Comment
Please, Sign In to add comment