First, basic type and value of reference type
Dynamic Properties
To create an object:
1. constructor Creation : New Object
2. literal creation :{}
Object Add Property: object . Property name = value
Object Add Method: object . Method Name =function () {}
Copy variable values
1. Reference type: If it is an assignment state, the reference type is common and one object is affected by each other
2. Basic type: If it is an assignment state, it is equivalent to copying a copy
(Clone version) 2 variables are separate and do not affect one another
C. passing Parameters
function ( parameters ): Parameters === "can only pass values
D. detection Type
instanceof=== Returns a Boolean value (object instanceof detection value (e.g. String,object))
if the match returns true
False if no match is returned
JavaScript storage **********
1. stack memory (base type)
2. heap memory (reference type)
Second, the scope in JS
Code ( variable | function ) The role in a certain place
1. at the global level, declared variables and functions are actually Properties or methods of the Window object.
2. For example, declaring a local variable in a function cannot be hit globally
the scope chain in JS
Internal access to external local variables or functions
External cannot access internal local variables or functions
Priority level
1. First find this layer ( this scope ) ===> Step-by-step outward lookup
2. Priority Level
variable ---> function ---> parameters ----> elevation
function (declaration)= = ="Does not look at the order of execution
Things that declare variables
var a ===> local a
WINDOW.A ====> Global a
a ====> belongs to the local a, also belongs to the global a
function fn () {
A = 10; ==> belong to the interior, also belong to the outside
Console.log (a);
var A; // after lifting the top a =10 not belong to the inside and outside , belong to the interior only
}
FN ();
Third, JS garbage collection mechanism
1. Mark Clear
One of the most commonly used garbage collection mechanisms
2. Reference Counting
The least common kind of garbage collection mechanism
3. Manual Removal
use a variable or object or function = = =Null (assigned to)
javascript-Scope-Memory