Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Scope refers to how accessable certain information is within JavaScript. Scope is either block (local), or global. In the instance
- of block scope, the information, such as a variable, will only be available within the container it is in, such as a function. Global scope
- however allows the information to be recalled later in your script regardless, and can even be accessed across files.
- Global variables are avoided because of the likelyhood of creating bugs in your code. When multiple seperate functions rely on a global
- variable, it can cause data to be altered and thus alter the outcome of a function inappropriately. Avoiding a variable that is global
- preserves the efficiancy of your code, as well as limits your time spent fixing broken code that was improperly altered.
- JavaScripts strict mode is a convenient way to avoid undeclared variables. Unless using the jQuery library, keeping const or let infront
- of your variables is standard. These keywords maintain the purity of our code, as well as mange the variables capabilities. When
- implementing strict mode in JavaScript, your code will relay an error anytime your variable is not properly declared with let or const.
- Side effects are unwanted results that are returned from your functions. They can happen anytime your code is not using proper variables or
- relies on global scope for certain variables. Pure code is code that is both determinate, meaning provides consistent results, and has no
- side effects. Your code should always be created the oure intent.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement