Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- What is scope?
- Refers to the current context of the code which could be either 'global' or 'local'. When one first starts a Javascript
- code it is in the global scope. Declared variables here are defined globally. The local scope lives inside of functions
- and each function, included nested functions, have their own local scope; however, any function defined within other
- functions will have linked scopes - inner local scopes are linked outwardly.
- Why are global variables aviod?
- Global variables can some code to be indeterminate (returns different values at times) which makes tracking down bugs
- difficult.
- What is strict mode?
- A way to opt into a restrictive variant of JavaScript which has different semantics than normal JavaScript. It
- eliminates some sillent errors and changes them into throw errors. It also fixes mistakes that make it difficult for
- JavaScript engines to perform optimizations, and it prohibits syntax that will be defined in the future. The option is
- enacted by witing the command 'use strict;' at the top of the file for global control or at the top of a function for
- local control.
- What are side effects, and what is a pure function?
- A side effect is when a functions is able to reach outside of its local scope to change values in other areas of
- the code. A function is "pure" when it is determinate (returns the same value consistently with the same set of inputs)
- and cuases no side effects in the proram overall.
Add Comment
Please, Sign In to add comment