a guest Oct 21st, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- Variable scope assignment
- What is a scope.
- A scope is when the code reads out a variable it determines if the variable is
- called out in a global scope(which means written out without a function or a local scope(written inside the function).
- If the variable if written globally that means you can call out that variable anywhere in your code, and that creates
- an unorganized code. Writing the variable in a function block only calls it that variable inside that function.
- Why are global variables avoided.
- The reason global variables are avoided is mainly to avoid using the same variable twice. Which means that your code
- will look unorganized. Global variables are also unintended to have side affects such as going back into the parent
- function and trying to find the variable in the parent function.
- is called out without a “let” or “const” the code will read it as undefined.
- What are side-effects and pure function.
- A side effect happens when a function reads a variable that was not called out, it reaches the parent function and
- tries to read the code from there. If the function does find the variable in the parent function then it will always
- use that varibale based off what the parent function has it set to.
RAW Paste Data