Object--function Special DescriptionIn JS, everything is an object.
Class (Prototype object) is actually an object, it is actually an instance of the function class, through which we can create our own object instances, which can be explained by the following code
function person () {
}
var a=new person ();
Window.alert (Person.constructor);
Object Instance--how to create an object instance var object name =new class name/prototype object name ();
Object Instance--How to access (use) a member variable of an object instance object instance name. property name;
object instance name [' Property name '];
The way an object instance name ["Variable name"] can be used to implement dynamic access variables, such as:
function person () {
}
var p1=new person ();
P1.name= "Shunping";
Supplementary Note: with Var and without var difference Look at the code:
the meaning of dynamic access variables:Can be used as a string to splice access specific look at the following code
Deepen Understanding To make the impression, we define a human (person) (including name, age)
Look at the following code
From the above code can be known, JS Object Transfer is also a reference to pass
var a=new person (); The new person () is a real data, and a is a reference to it
Deep Understanding:
When will the contents of the heap be recycled?
Object Recycling Mechanism (GC), garbage collection (GC) is how to determine the contents of the heap is garbage, memory by JS engine management, JS engine is a part of the browser,JS engine maintenance of a table
Garbage collection mechanism is a passive recovery method, when the GC to call, we are not aware of, anyway not always in the call of
In JS there is also a proactive way to remove the memory, the active release of RAM: delete Delete can only delete the properties of an object, you can not directly delete an object as follows:
Delete a.age; Delete the age attribute directly, even if B is not empty, b.age can not access it.
delete A; That's not true.
Delete Deletes an object's properties directly
Delete Object name. property//This will immediately release this property space of the object
Look at one more code:
var a=new person ();
a.age=10;
A.name= "Xiao Ming";
var b=a;
document.write (B.name); Output Xiao Ming
b.age=200;
document.write (A.age); Output 200