日期:2014-05-16  浏览次数:20305 次

JavaScript基本概念(二)
Passing Objects
Here's an example of how you can assign an object to another variable and then make a
change to the copy. As a result, the original object is also changed:
>>> var original = {howmany: 1};
>>> var copy = original;
>>> copy.howmany
1
>>> copy.howmany = 100;
100
>>> original.howmany
100



Comparing Objects
When you compare objects, you'll get true only if you compare two references to the same object. Comparing two distinct objects that happen to have the exact same methods and properties will return false.
Let's create two objects that look the same:
>>> var fido = {breed: 'dog'};
>>> var benji = {breed: 'dog'};
Comparing them will return false:
>>> benji === fido
false
>>> benji == fido
false