Home > Web Front-end > JS Tutorial > body text

Introduction to the differences between js objects created_Basic knowledge

WBOY
Release: 2016-05-16 16:41:08
Original
1247 people have browsed it

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
Copy after login

B’s will not

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template