Skip to content

Instantly share code, notes, and snippets.

@d11z
Last active April 18, 2018 19:13
Show Gist options
  • Save d11z/09c7460b32806f4254f43a3e9ee39634 to your computer and use it in GitHub Desktop.
Save d11z/09c7460b32806f4254f43a3e9ee39634 to your computer and use it in GitHub Desktop.
Thinkful In Your Own Words
What is scope?
Scope determines whether variables can or can't be accessed in different places in your code. Globally scoped variables can be accessed anywhere in your code. When a variable is declared outside of a function it is globally scoped. Global scope can span across different files. Variables defined inside functions are locally scoped, meaning they can only be accessed within that function. This means that variable names can have the same name as long as they are defined in different fuctions. You can define a variable with the same name as a global variable inside of a function and it will be seperate from the global variable.
Why are global variables avoided?
We avoid global variables because they can cause unintended side effects. This can lead to code that is difficult to debug.
Explain JavaScript's strict mode
Strict mode makes it easier to write more robust JavaScript code. It throws errors instead of silently accepting bad syntax. It makes it impossible to create global variables.
What are side effects, and what is a pure function?
A side effect is when a function reaches outside it's local scope and alters a variable. A pure function is a function that doesn't rely on or modify variables outside of it's own scope. It will always return the same result given the same parameters.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment