Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. Question 1: From my understanding scope is the order in which commands are executed. A variable in the global scope has the ability to be accessed from anywhere in the scope. It also can be manipulated and/or changed by funtions anywhere in the scope. Variables inside of a block scope can only be effected by functions or other commands within that scope. Unless defined within a block scope, the global vairable take precedence when called.
  2. Question 2: Global variables are avoided when dealing with various functions, as many bugs and errors can be created from uninteneded side effects. When those side effects happen, finding the root of the issue can become daunting, because you have to figure out why your code is being effected the way it is and why. Global variables will manipulate data or functions that you may not want manipulated.
  3. Question 3: The strict mode in Javascript is an option that will present an error anytime you declare a variable without keywords const or let. This is a safeguard against creating global variables unintentionally.
  4. Question 4: A side effect is when a function goes outside its local scope into the global scope and affects the value in the global scope. A side effect can occur intentionally or untinentionally. The function is pure when no side effects exist and when the same inputs are given, the value of results of the function will alway be the same.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement