Skip to content

Instantly share code, notes, and snippets.

@lucasjlatour
Last active March 31, 2020 21:48
Show Gist options
  • Save lucasjlatour/894c5d66729938904d96f38522f7fe6f to your computer and use it in GitHub Desktop.
Save lucasjlatour/894c5d66729938904d96f38522f7fe6f to your computer and use it in GitHub Desktop.
Scope is a set of rules that determine how widely accesible a variable is in a program. By accessible I mean that a variable's
value could be used or changed.
Block scope determines that a variable is only accessible within a block. Global scope is when a variable is accesible through out a program.
Global can also sometimes be accessed in different files.
Global variables are avoided because they can cause code to become indeterminate (having different results under different conditions)
which leads to errors and code that is hard to debug.
Strict mode requires that every declared variable in a program must use the keywords "let" or "const" in their declaration.
By default, it's a best practice to put 'use strict' at the top of your program.
A side effect is when a function makes changes to a value outside of its scope. A function that always returns the same results with the same inputs is a determinate function.
A pure function is determinate and has no side effects. You should generally try to use pure functions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment