Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Scope is about how and when a varible is activated depending on it's place in the code.
- Some variables are only active when in a certain block of code, this is known as local scope.
- Other variables are active through the entirety of the code, this is global scope.
- If a varible is defined within a block of code, or locally, it won't interfere with anything outside it's scope.
- However, if a scope is drawn into the block of code from a global scope, the activation of the variable may interfer with the rest of the code.
- To prevent side effects from variable activation in the global scope, it's best to apply the 'use strict' command at the beginning of coding progams.
- This will prompt an error message whenever a variable is not explicetly defined with stric variables like let and const.
- These variable declerations will ensure variables are only declered withint he desired scope.
- When a fuction has no side effects and always returns a value with a given input it is considered pure, how good, clean code should be.
Add Comment
Please, Sign In to add comment