a guest Jul 18th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- What is scope?
- Why are global variables avoided?
- They are avoided because of the unintended side effects of when a function reaches outside of its local scope and alters the value of the global variable. The problem is because other blocks of code may be relying on that global variable to remain constant. When this happens it can create indeterminate functions, where they return different values each time which makes debugging much more of a messy chore.
- What are side effects, and what is a pure function?
- A side effect is when a function reaches outside of its block and alters the value of a global variable. A pure function is one that is determinate and has no side effects. A determinate function is one that always returns the same value when given the same inputs.
RAW Paste Data