Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. 1. Scope is a property of variables and determine which parts of the program a variable is accessible in. The Scope Chain refers to the ladder of scope.
  2. Starting with Block Scope, meaning its only available to the code enclosed in { } curly braces.
  3. And ending at the top with Global Scope, which is outside of all functions in the file.
  4.  
  5. 2. Global variables are available to any and every part of the progam, which can cause problems when the variable is changed in unintended ways by one function and no longer fit into a another function.
  6.  
  7. 3. You can enable strict mode by adding "'use strict';" at the top of your JS file.
  8. While strict mode is enabled, you will get an error wherever you try to declare a variable without using 'let' or 'const'.
  9. This prevents you from accidentally scoping globally, which is good to prevent because errors that arise from global variables are difficult to debug.
  10.  
  11. 4. Side effects are any effect that are a result of a function reaching outside it's own local scope.
  12. A pure function is any function which has no side effects (it doesn't ever reach outside it's scope) and is determinate.
  13. Determinate functions are those that always return the same value when given the same parameters, meaning it isn't effected by the side effects of other impure functions.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement