Js basic note and js note
Three-scope chain
1. the variables defined in the function are local variables and the layer of the scope chain. The scope chain is searched from the inside out. If it is found, the search is stopped.
2. It does not have its own block-level scope (it refers to the block of code closed by curly brackets), such as the if for statement.
3. variables declared without the keyword var are global variables. When the keyword var is used to declare a variable, the variable will be added to the latest scope.
3. Combined with constructor and prototype
Prototype attributes
In general, it allows all object instances to share its attributes and methods.
Constructor is used to define instance attributes. prototype is used to define shared attributes and methods.
Differences between basic and reference types
Basic Type: occupies a fixed amount of space in the memory, and their values are stored in the stack memory.
Reference Type: the object is copied to the newly assigned variable, but the pointer is copied, And the Pointer Points to the same object in the heap.
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.