Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. Scope is the idea of where a function gathers or views the variables and values it’s looking for.
  2. It will start in the function itself and if it cannot find what it’s looking for it will bubble up into the parent.
  3. This will happen until it reaches the global level or in other words a variables that are accessible to all
  4. functions and sometimes other files. If the variable or value it’s found even there it will throw an error.
  5. These types of global variables should be avoided since the functions may cause side effects by un-intentionally
  6. altering these global variables and changing the results of other functions. When a function that takes a simple
  7. input begins showing random results its considered a in-determinate function and is likely caused by global variables.
  8. When a function is free from global variables and returns consistent results it is considered to be a pure function.
  9. This is what we should strive to write. To help us write this type of consistent code we can use ‘strict’ mode.
  10. When in this mode is a variable is created without deceleration of let or const , it will throw an error to inform us.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement