Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. Answers
  2.  
  3. 1. What is scope? Your explanation should include the idea of global vs. block scope.
  4.  
  5. Scope is about how a variable is visible in the code. Global scope means they can be accessed from anywhere in the code. Block scope means they can only be accessed from inside the block they are in. A block scope would be defined with curly braces.
  6.  
  7. 2. Why are global variables avoided?
  8.  
  9. Global variables are avoided because they can end up causing bugs if a variable with the same name is used somewhere else in the code. This could happen especially if another developer that isn't familiar with the code is working on it.
  10.  
  11. 3. Explain JavaScript's strict mode
  12.  
  13. The JavaScript strict mode which you can use by writing "use strict"; at the top of a javascript file is used so you can write secure javascript. One example is that with strict mode any code with global undeclared variables won't run.
  14.  
  15. 4. What are side effects, and what is a pure function?
  16.  
  17. Side effects means if a variable changes the value of what is in another function. A pure function is basically the opposite in that a variable outside the scope isn't changed at all.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement