Guest User

Untitled

a guest
Nov 12th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. Scope is the reach of variables that are included within a file. When you have global scope, that means that a variable that is declared will be reflected throughout the program, and it applies to every variable outside of a function. Block scope, on the other hand, is related only to a variable that is declared within a function, meaning that the variable will only be applied within that function. Global variables are generally to be avoided due to the fact that it tends to cause side effects, in which the scope of the variable isn't limited to a local or block level, but effects a greater-hierarchy scope, such as a parent variable. Global is general avoided due to the unintended side effects that may come with it. Global variables can be created when the keywords 'let' or 'const' aren't used to make a variable - so 'strict mode', when implemented returns an error when you have variables that are created without the keywords 'let' and 'const', letting you know that you have global variables.
  2.  
  3. Side effects occur when a variable goes outside of its local scope to effect parent scope and therefore cause changes in places where it should not. These side effects can be unintended which can lead to the formation of an indeterminate function, of which you're never really sure what output you're going to get. A pure function, then is one in which it is determinate and has no side effects, meaning that you will get the same output given a set of inpouts.
Add Comment
Please, Sign In to add comment