Scope is part of the reasoning of how code works in regards to variables. Global scope allows accessing variables everywhere, whereas local scope is bound to the block at which it is defined.
Global variables are avoided to prevent unintended side effects.
'Strict mode' forces the declaration of variables. More specifically, strict mode looks for variables to be declared with let
or const
. If not, then the program will throw an error.
This can be accomplished by including a 'use strict' at the top of the JavaScript file.
Side effects are unintended consequences of a function. They occur when a function has effect outside of it's scope.
A pure function has no unintended side effects, and always produces a consistent output with the same parameters.