Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. Scope determines the visabilityand accessibility of variables. It is a set of riles that define which parts of our program are able
  2. to interact with particular variables. There are 2 types of scope: Global and Block. Variables declared outside a function is global
  3. scope and variables declared insidie are within the block scope. With block scope, variables can only be accessed from within the
  4. block whereas, with the global scope, all scripts and functions on a web page can access the variable.
  5.  
  6. Global variables should be avoided because they tend to make unintended side effects in a program more likely. This almost always
  7. generates code that becomes indeterminate, which returns one value sometimes
  8. and another value at other times. This makes it very difficult to track down bugs.
  9.  
  10. Strict mode is a setting applied at the top of a JS file. Strict mode makes it so thtat any time a variable is declared without let
  11. or const keyword, an error will be triggered. Strict mode ensures there is no use of global variables in your code.
  12.  
  13. A side effect is when a function reaches outside its local scope up into a parent scope and alters a value that lives there. A pure
  14. function is when your code is both determinate and has no side effects.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement