Examples of differences between js object creation and js object Creation
A: var obj1 = obj2 = new Object ();
And
B: var obj1 = new Object (),
Obj2 = new Object ();
There are two different assignment methods, which lead to different results. Please pay attention to them ~
A will direct two objects to the same memory address, so that the content of the two objects is consistent.
Var t1 = t2 = new Object (); t1.name = 'hello'; t2.name = 'kakao'; t1.name = null; alert (t2.name); // The result is null.
B Does not.
JS issues with object Creation
You can understand the features of js. When this pointer is used in a function, you need to use the new keyword to obtain its instance. Otherwise, the this pointer cannot find the target.
In addition, js does not have the class syntax at all.
How to create objects in js
.... Objects in js are similar to those in java, but they cannot be constructed simply!
The usage is similar to that of java!