Home >Web Front-end >JS Tutorial >Introduction to the differences between js objects created_Basic knowledge
A : var obj1 = obj2 = new Object();
and
B : var obj1 = new Object(),
obj2 = new Object();
are two different assignment methods, resulting in different results. Please pay attention~
A will point the two objects to the same memory address, causing the contents of the two objects to be consistent
var t1 = t2 = new Object(); t1.name = 'hello'; t2.name = 'kao'; t1.name = null; alert(t2.name); // 结果为 null
B’s will not