Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Scope determines the visabilityand accessibility of variables. It is a set of riles that define which parts of our program are able
- to interact with particular variables. There are 2 types of scope: Global and Block. Variables declared outside a function is global
- scope and variables declared insidie are within the block scope. With block scope, variables can only be accessed from within the
- block whereas, with the global scope, all scripts and functions on a web page can access the variable.
- Global variables should be avoided because they tend to make unintended side effects in a program more likely. This almost always
- generates code that becomes indeterminate, which returns one value sometimes
- and another value at other times. This makes it very difficult to track down bugs.
- Strict mode is a setting applied at the top of a JS file. Strict mode makes it so thtat any time a variable is declared without let
- or const keyword, an error will be triggered. Strict mode ensures there is no use of global variables in your code.
- A side effect is when a function reaches outside its local scope up into a parent scope and alters a value that lives there. A pure
- function is when your code is both determinate and has no side effects.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement