Created
May 1, 2018 21:33
-
-
Save escottalexander/1ab84d178d4eb03e166657060d2b4799 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
What is scope? Your explanation should include the idea of global vs. local scope. | |
Scope is the idea of where a variable is accessible. Global scope means that the variable resides outside of any function and as a result can be accessed by anything. Local scope would mean that the variable is accessible only inside it's original function. | |
Why are global variables avoided? | |
Global variables can cause issues because that variable can be referenced by any function in the program and may be altered accidentally, rendering it useless to its original purpose. | |
Explain JavaScript's strict mode | |
Strict mode raises a reference error when a variable is defined without let or const. It helps to keep the code collaboration friendly and bug free. | |
What are side effects, and what is a pure function? | |
Side effects are unintended issues that arise because a function is reaching outside itself and altering a different part of the program. A pure function is one that does not do this. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That makes sense. I suppose most of the Math functions are pure, such as Math.round, Math.pow, and Math.sqrt. One that is not pure would be Math.random. Obviously this one is not pure because it does not give the same output when you give it the same input.