如果两个变量的内容相同,为什么我会收到错误消息?
function A() { return {k:'k'}; }
function B() { return {k:'k'}; }
var a = new A;
var b = new B;
var s='';
for (prop in a) {
if (typeof a[prop] != "function") {
s += "a[" + prop + "] = " + a[prop] + "; ";
}
}
alert(s);
for (prop in b) {
if (typeof b[prop] != "function") {
s += "b[" + prop + "] = " + b[prop] + "; ";
}
}
alert(s);
alert( a == b ); // false?
即使我同时分配 a 和 b 相同的功能也会发生同样的情况
var obj = {};
function A() { return {k:'k'}; }
var a = new A;
var b = new A;
alert( a == b ); // false?
和这里一样
k={zor:1};
b={zor:1};
alert(k==b); //false