Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. What is scope? Your explanation should include the idea of global vs. block scope.
  2.  
  3. Answer: Scope is where variables, functions determine where is can be accessible during code runtime. Global scope is a variable that is declared outside of the functions and block scope is variable declared inside the function.
  4. Example:
  5.  
  6. let myName = 'Hoang'; <-----Global Scope
  7.  
  8. function logName () {
  9. let myName = 'Hoang'; <-------Block Scope
  10. }
  11.  
  12.  
  13. Why are global variables avoided?
  14. Global scope should be avoided because once you declared it, it is available everywhere in your code and it can cause your code to be indeterminate, there are exception but it is best to avoide Global Scope
  15.  
  16. Explain JavaScript's strict mode
  17. JavaScript's Strict Mode will notify you anytime you declares a variable without using let or const, an error will triggered.
  18.  
  19.  
  20. What are side effects, and what is a pure function?
  21. side effects is when function reaches outside its local scope up into a parent scop and alters a value that lives there
  22. a pure function is when both determinate and has no side effect.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement