Advertisement
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 where variables are defined. A global scope is where a variable is available through the entire Javascript file wheras
- local scope would be a variable that is defined and accessable only within a certain part of the file such as a function
- Why are global variables avoided?
- A global variable being available through a whole document can lead to that variable being altered in different ways throught the whole
- file making a function indeterminate (returns different values in certain areas using the same input) and will make tracking down a bug
- difficult as with the golbal scope it could be altered anywhere in the code.
- Explain JavaScript's strict mode
- JavaScript strict mode is a mode you can enter at the top of your javascript file that will force global variables to return undefined
- value
- What are side effects, and what is a pure function?
- Side effects are intended/unintended consequences of a function outside of the declared function itself. A pure function is one with no
- side effects and is a determinate function (always returning the same value when passed the same input).
- Explain variable hoisting in JavaScript.
- Variable hoisting refers to the way JavaScript parses a file. Javascript will pass over the file looking for all variable declarations
- and then moves them to the top of their respective scope.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement