Guest User

Untitled

a guest
Jan 17th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. Questions
  2.  
  3. What is Scope?
  4. Scope, as literally defined in checkpoint 10, is “a set of rules that define which parts of your code can access a particular variable”. What this refers to is the idea that a variable can be referenced by your code either globally, outside of a specific function or even from a different script altogether, or within a block, which is the contents of a specific function. Variables within a block cannot be referenced outside of that function.
  5.  
  6. Why are Global Variables avoided?
  7. Global variables are generally avoided because they can unintentionally mutate your code, break functions, and in general just contribute to buggier code. Because it’s not always obvious when you’re exploring deep into someone else’s code what all the associated global variables are, it can also make collaborating with multiple people needlessly more difficult.
  8.  
  9. Explain JavaScript’s Strict Mode
  10. JavaScript’s ‘Strict Mode’ is enabled by by placing the command “ ‘use strict’; “ at the top of a file. When enabled, Strict Mode triggers an error anytime a global variable is mutated, altered without the use of 'let' or 'var', within a block. Using Strict Mode is good general practice, as it helps to combat the unintended mutation of global variables.
  11.  
  12. What are side effects, and what is a pure function?
  13. A side effect occurs when a function is made, either intentionally or unintentionally, to go backwards through the hierarchy of code to alter a value within the scope of one of its parents.
  14. A pure function is a function that is both determinate and has no UNINTENDED side effects. This means that to be pure, a function must execute in a manner which is both consistent, and respectful of its parent functions.
Add Comment
Please, Sign In to add comment