Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. What is scope?
  2. Scope defines what variables are accessible from different points in code. Variables declared in global scope can be accessed
  3. from anywhere in the code. Variables declared in block scope can only be accessed within that block of code, for example,
  4. variables declared inside a function are only accessible inside that function.
  5.  
  6. Why are global variables avoided?
  7. Since global variable are accessible everywhere, values can unintentionally be altered throughout the code. This results in
  8. bugs that are hard to find and can create multiple problems across a program that are difficult to fix.
  9.  
  10. Explain JavaScript's strict mode.
  11. Invoking strict mode at the top of a file or function will trigger an error any time a variable is declared without let or
  12. const. It is possible to declar a variable without let or const, but this exposes the value to mutation. Without strict mode,
  13. no errors are thrown, and a programmer can possibly continue writing without being aware of the problems being caused. Strict
  14. mode will throw errors whenever a variable is declared without const or let, thus preventing mutations.
  15.  
  16. What are side effects, and what is a pure function?
  17. A side effect occurs when a function looks outside its local scope and alters a value there. A pure function is one that
  18. is both determinate and has no side effects. A determinate function will always return the same value as long as it is given
  19. the same inputs. A pure function will also only check its local scope for a variable value.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement