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. local scope.
- Why are global variables avoided?
- Explain JavaScript's strict mode
- What are side effects, and what is a pure function?
- 1.Scope is used to avoid bugs and to be able to collaborate easier. It is a set of rules that defines how
- the variables in your code can be accessed. Global scope can be accessed across files and is more likely to
- have side effects which leds to bugs. Local scope takes precedence over global scope using the scope chain which begins
- with the local varibales.
- 2. Global variabes should be avoided because it makes it harder to find bugs in your code as well as harder to collaborate
- with others. It can also extend across your files which could alter values of variables.
- 3. JavaScript strict mode makes chnges to the normal JS semantics. It eliminates some JS silent errors, fixes mistakes and
- prohibits some syntax. It does not apply to block statments in curly brackets.
- 4. Side effects are whe a variable reaches outside its local scope into the parent scop and alters the value. Pure function
- means that it is determinate and has no side effects. (Determinate means that it returns same value)
Add Comment
Please, Sign In to add comment