Created
February 3, 2018 17:56
-
-
Save RyanOkamuro/c7b039564062eb12f61c18c8bab47e7e to your computer and use it in GitHub Desktop.
Challenge: In your own words
This file contains hidden or 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 determines whether or not you want the selected variables to be affected by the code you write. Global scope refers to all the variables you write will be affected by your code. Local scope refers to only a "selected" variables/block/part will be affected by the code as opposed to affecting every variable. | |
| Why are global variables avoided? | |
| They may result in unintended side affects or indeterminate coding. Uninteded side affects occur when other variables are affected other than the ones you specified. Indeterminate coding occurs when sometimes you receive the correct output for your input but at other times receive another output. | |
| Explain JavaScript's strict mode | |
| When defining a variable, it must use "let or const" to specify the scope. In strict mode, an error message will occur to remind the user to use "let or const" if they obmit these words when defining at variable. | |
| ----What does this mean: | |
| One of the problem points we identified above is that getOptionName creates a variable without using the let (or a const). If firstOption was not already defined in the global scope, getOptionName would create it, and if it is in the global scope, getOptionName will mutate it (assuming it's not a const). | |
| What are side effects, and what is a pure function? | |
| A side effect occurs when other variables are affected by your code other than the ones you specified to be affected. | |
| A pure function is when it is determinate and has no side affected. Determinate meaning, for the input code, you get the exact output you expected. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment