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.
- A scope is where a variable can and can not be accessed. For example, variables in a global scope can be accessed anywhere on the
- page and are not restricted to a function. On the other hand, a variable from local scope can only be assesed within the funtion that
- it is contained in. This can prevent errors or unintended results because variables can only be used within it's function.
- Why are global variables avoided?
- Global variables area avoided due to the fact that they can be accessesd anywhere on a page, and even across differet files. This can cause
- unintended mistakes to happen as you may call a global variable when you were not intending on doing so.
- Explain JavaScript's strict mode
- JavaScript's script mode is when you place the string 'use strict' before wrting a line of code. This causes a varible to must be declared
- using const or let. If a variable is not declared using let or const, then an error will occur.
- What are side effects, and what is a pure function?
- Side effects are when a function moves out of its local scope and changes a global scope variable. A pure function is when a function
- does what it is supposed to do and has no side effects.
Add Comment
Please, Sign In to add comment