Skip to content

Instantly share code, notes, and snippets.

@DianeCho
Created October 21, 2017 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DianeCho/1daa9e220246bd73e01470a9b4614240 to your computer and use it in GitHub Desktop.
Save DianeCho/1daa9e220246bd73e01470a9b4614240 to your computer and use it in GitHub Desktop.
Scopes in JS
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