Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. What is scope ?
  2. Scope is a region which has its own inhabitants but is also allowed access to inhabitants of its parent regions.
  3. Let's assume that globals scope starts at the national level. State can be thoght of as a funcion which exists in a nation. Within this function another function exists called city.
  4. If a programmer named Noel Duarte is required by a sofware company in a city named Scope Francisco, the company will first check if someone by that name exists in the city since it'll be more efficient than looking outside (at least that's what President Donald Scope told the company).
  5. If he is not found in the city, the company looks uo in the state of Scopefonia, and if a Noel Duarte is still not found, the company looks up in the whole country.
  6. If a Noel is found at each scope level, their permit comes into play. Noel registered at city level can only work within the city. A Noel registered in the state office can work in the whole state, which means in other cities too. Whereas a Noel registered with a National Permit can work anywhere in the country, and is subsequently more expensive.
  7. Lastly this country United Scopes of America has one peculiar rule, at each scope level there can't be more than two persons with the same particular name.
  8.  
  9. Why are global variables avoided ?
  10. A program typically uses tens or hundreds of functions.If you pass a global variable to some of these functions it will be tedious to keep track of the changes taking place in its value.
  11.  
  12.  
  13. Explain Js strict mode
  14. JS strict mode can be enabled by typing 'use strict' at the beginning of your js file.
  15. It prevents misuse of Js' leiniency like provision to use globals.
  16.  
  17. What are side effects ? Whats a pure function ?
  18. Side effects are when a function changes the value of a global variable
  19. A pure function is a function which is determinate and does not have any side effects.
  20.  
  21. Explain variable hoisting in JS
  22. Js interpeter makes a pass through the program and looks for declared functions and variables. During this pass it does not execute any statement but assigns values to variables and scopes to functions.
  23. This is called variable hoisting
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement