Guest User

Untitled

a guest
Sep 25th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. What is scope? Your explanation should include the idea of global vs. local scope.
  2. Scope refers to the scale that variables will be able to affect. Scope can be local or global. Local variables only affect
  3. code within its function. Global variables can affect code within the entire javascript file, or even multiple files.
  4.  
  5. Why are global variables avoided?
  6. Global variables affect all the code in a project and can cause problems if they are unintentionally referenced down the line.
  7. As a project gets bigger, global code can be harder to control and can cause problems that are difficult to find.
  8.  
  9. Explain JavaScript's strict mode
  10. Strict mode sends an `Uncaught ReferenceError` whenever you try to create a variable without its 'const' or 'let' keywords.
  11. This is very useful to keep yourself from using global variables without intending to. To initiate strict mode you type in
  12. 'use strict'; at the top of a javascript document.
  13.  
  14. What are side effects, and what is a pure function?
  15. Side effects can happen if your code produces unintended results. Side effects can be caused by global variables affecting
  16. variables that you didn't intend to have interacting with each other. A pure function is both determinate and doesn't have
  17. side effects. Determinate functions are called so when it returns the same value every time the same input is given.
Add Comment
Please, Sign In to add comment