当前位置: 代码迷 >> JavaScript >> JavaScript基本概念(2)
  详细解决方案

JavaScript基本概念(2)

热度:177   发布时间:2012-10-08 19:54:56.0
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
  相关解决方案