Three-scope chain
The variables defined within the 1 function are local variables, which are the inner layer of the scope chain. The scope chain is looked up from inside out, and the search stops when found
2 does not have its own block-level scope (refers to a block of code enclosed by curly braces), such as the IF for statement
3 variables declared without the keyword VAR are global variables that are added to the nearest scope when the variable is declared with the VAR keyword.
3. Combining constructors and prototype patterns
Prototype property
The popular understanding is that it allows instances of all objects to share the properties and methods it contains.
Constructors are used to define instance properties, and prototype patterns are used to define shared properties and methods.
Distinguish between basic types and reference types
Base type: Occupies a fixed size of space in memory, and their values are stored in the stack memory.
Reference type: The object is copied to the newly allocated variable, but the pointer is copied, and the pointer points to the same object in the heap.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
JS Basic Small Note