a guest Apr 20th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- Scope refers to the idea that variables can be referenced by multiple levels of code and functions. When a function sees a variable referenced, first it will search for the variable within the function and if it does not find it there (locally), then it will see if it can find the variable referenced outside of a function in the main bloack of code (global) or in another accompanying file.
- Global variables should be avoided when possible because they are susceptible to being altered by functions that use them in often unexpected or detremental ways. It also makes it very difficult to trace why a certain variable might be giving a different then expected result because it could be any number of potential functions that altered it.
- A side effect is when a function creates effects outside of its intended scope. For example if it were to alter a global variable inadvertantly. A function is determinate when it will perform the same everytime as long as the same inputs are passed to it. In order for a punction to be considered 'pure', it needs to be both side effect free and determinate.
RAW Paste Data