Created
October 21, 2017 14:19
-
-
Save DianeCho/1daa9e220246bd73e01470a9b4614240 to your computer and use it in GitHub Desktop.
Scopes in JS
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: Two types- local or global. It determines the accessibility of variables, objects, and functions from different parts of the code. | |
Local Scope: Variables declared within the function. It can only be accessed within that function | |
Global Scope: A variable declared outside a function. All scripts and functions can access it. | |
Why are global variables avoided? | |
Because it can overwrite window variables or functions | |
Explain JavaScript's strict mode | |
When the value is undefined | |
What are side effects, and what is a pure function? | |
Pure function: | |
Given the same input, will always return the same output. | |
Produces no side effects. | |
Side effects: | |
Is any effect other than that return value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment