Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. What is scope? Your explanation should include the idea of global vs. local scope.
  2. Scope is defined as how our variables can be accessed in different areas of the code. Global scope is when you declare a variable that will be used throughout all the code. Local variables are variables that are defined within a function. They only apply while in that function when defined by var.
  3. Why are global variables avoided?
  4. Global variables should be avoided because they cause unintended side effects, which means local variables could reach up into a parent element and change various outputs in your codes that can cause bugs. Global variables means your code will be indeterminte when we should always be able to determine the outputs of our code.
  5. Explain JavaScript's strict mode
  6. Strict mode in Javascript flags you everytime you create a variable without use var.
  7. What are side effects, and what is a pure function?
  8. A side effect is when your local variable reaches outside its scope and into a parent scope and can alter what was in the local scope. A pure function has no side effects and is determinite making it less likley that we will have bugs in our code when doing hundreds of functions and variables.
  9. Explain variable hoisting in JavaScript.
  10. Hoisting refers to how the page will load our javascript. Typically variables and functions are moved to the top and read first and do not read how the human eye would have read them.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement