Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- What is scope? Your explanation should include the idea of global vs. block scope.
- Answer: Scope is where variables, functions determine where is can be accessible during code runtime. Global scope is a variable that is declared outside of the functions and block scope is variable declared inside the function.
- Example:
- let myName = 'Hoang'; <-----Global Scope
- function logName () {
- let myName = 'Hoang'; <-------Block Scope
- }
- Why are global variables avoided?
- Global scope should be avoided because once you declared it, it is available everywhere in your code and it can cause your code to be indeterminate, there are exception but it is best to avoide Global Scope
- Explain JavaScript's strict mode
- JavaScript's Strict Mode will notify you anytime you declares a variable without using let or const, an error will triggered.
- What are side effects, and what is a pure function?
- side effects is when function reaches outside its local scope up into a parent scop and alters a value that lives there
- a pure function is when both determinate and has no side effect.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement