Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. Scope is the accessibility of variables. It is based on the variables available in a file(s). There are two types of scope, global and local.
  2. A variable that is declared outside of a function body and that can be accessed and modified across files has global scope. Local scope
  3. refers to a variable that is only accessible within a function. Global variables are to be avoided because it can create buggy code. It
  4. could cause unintentional side effects and change/ alter the physical outcome of your code. Javascript has a command called ‘strict mode’
  5. to account for any variables that are declared without the var keyword. It helps to avoid code that is hard to debug. A side effect is the
  6. result of a function that reaches outside of its local scope by accessing a global variable. This may cause an intended change, but may
  7. also cause an unintended change, which may return a different value than intended. On the other hand, a pure function is a function free
  8. of side effects and will always return the same value. To hoist means to raise up. In the context of JavaScript, hoisting is the behavior
  9. in which variables and function declarations are processed before any code is executed. Basically, no matter where a variable is declared,
  10. it will equate to declaring it at the top of its scope.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement