Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- What is scope? Your explanation should include the idea of global vs. local scope.
- Scope refers to the scale that variables will be able to affect. Scope can be local or global. Local variables only affect
- code within its function. Global variables can affect code within the entire javascript file, or even multiple files.
- Why are global variables avoided?
- Global variables affect all the code in a project and can cause problems if they are unintentionally referenced down the line.
- As a project gets bigger, global code can be harder to control and can cause problems that are difficult to find.
- Explain JavaScript's strict mode
- Strict mode sends an `Uncaught ReferenceError` whenever you try to create a variable without its 'const' or 'let' keywords.
- This is very useful to keep yourself from using global variables without intending to. To initiate strict mode you type in
- 'use strict'; at the top of a javascript document.
- What are side effects, and what is a pure function?
- Side effects can happen if your code produces unintended results. Side effects can be caused by global variables affecting
- variables that you didn't intend to have interacting with each other. A pure function is both determinate and doesn't have
- side effects. Determinate functions are called so when it returns the same value every time the same input is given.
Add Comment
Please, Sign In to add comment