Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. Q: What is scope? Your explanation should include the idea of global vs. block scope.
  2. A: Variable scope is a set of rules that define which parts of code can access a particular variable, which allows us to reuse variable names at different points. When using "let" and "const", there are two types of scope. The first one is global scope, which indicates variables declared outside of a function, it is available everywhere in the code. And the second one is block scope, it is only accessible within the function's block of instructions.
  3.  
  4. Q: Why are global variables avoided?
  5. A: Global variables can be retrieved and altered anywhere in the code, their names are not unique and they tend to make unintended side effects, which makes the code indeterminate.
  6.  
  7. Q: Explain JavaScript's strict mode.
  8. A: The strict mode triggers error whenever a variable is declared without "let" or "const", it's a safer feature of JavaScript.
  9.  
  10. Q: What are side effects, and what is a pure function?
  11. A: A side effect is when a called function reaches outside its local scope and gets into a parent scope then alters a value there. A pure function is determinate, which means given the same inputs there always returns the same outputs, and also a pure function doesn't have side effects. 
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement