Advertisement
Guest User

Untitled

a guest
Oct 21st, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. What is scope of a variable:
  2. Scope is the cumulative extent of a program or application. It includes the variables and functions within the defined parent, whether that be a function or application. a variable's scope will allow the varibale to be called withi a whole file or just within the function for which it is called; Most notably, it includes what can be referenced and what is unable for a function or other to call.
  3.  
  4. Why are global variables avoided:
  5. Global variables are avoided becuase they cuase the code to be indeterminate. A function may produce differing results with various inputed parameters.
  6.  
  7. Javascript's Strict Mode:
  8. Strict mode is a way to make global variables more reliable or determinate. Strict Mode requires the variables to be explicitly named. Strict Mode will throw erros when a referenced variable is not consistent with a variable in existence.
  9. Strict Mode does not accept bad syntax and requires the contributors to adhere to the current standards being utilized within the project.
  10. Strict mode has the opportunity to be called within the script's file, enforcing the entire scope of the items within the file.
  11. Script mode also has the opportunity to be called within a function, requiring that the variable's defined within the function can not be used outside of that strict function. Make sure to declare variables before I call them.
  12.  
  13. Side Effects:
  14. unintended results from a variable or function reaching outside of the local scope of that element. It may reach to a parent element, tracing back information and elements defined in other locations of the project. Ultimately, if may make a function unreliable. While the strict will limit, side effects are due to non-limitations.
  15.  
  16. Pure Function:
  17. a pure function would not affect a global variable. only deals with and returns data within the local scope.
  18.  
  19. Hoisting:
  20. hoisting refers to the way the javascript renders variables when it is parsing and executing; In order to udnerstand hoisting, one must understand the order in which a browser would read a script file. Javascript first reads the variables defined throughout a scope. It would then read through the functions and save memory for which. Functions and variables which are defined within a function, can only be used by calling that parent function.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement