Sample introduction to the difference between js creation objects
- 2020-03-30 03:36:05
- OfStack
A: var obj1 = obj2 = new Object();
with
B: var obj1 = new Object(),
Obj2 = new Object ();
There are two different ways to assign values, resulting in different results
A will point two objects to the same memory address, resulting in the contents of the two objects being the same
var t1 = t2 = new Object();
t1.name = 'hello';
t2.name = 'kao';
t1.name = null;
alert(t2.name); // The results for null
B doesn't