var declared; //声明变量。
if (declared == undefined) //测试变量。
document.write("declared has not been given a value.");if (typeOf(notDeclared) == "undefined")
document.write("notDeclared has not been defined.");-------------
if (declared == 0) //测试变量。
document.write("the value is 0 .");
if (declared == undefined) //测试变量。
document.write("declared has not been given a value.");if (typeOf(notDeclared) == "undefined")
document.write("notDeclared has not been defined.");-------------
if (declared == 0) //测试变量。
document.write("the value is 0 .");
空是空字符串
var declared = "";
if (a == "")alert("zero");
a = 0 ;
if (a == "")alert("zero 2");
a = "";
if (a == 0 )alert("zero 3");
if (a == "")alert("zero");
a = new String(0) ;
if (a == "")alert("zero 2");
a = new String("");
if (a == 0 )alert("zero 3");
if (a == "")alert("zero");
a = 0 ;
if (a === "")alert(a);
a = "";
if (a === 0 )alert(a);
nullzero
new String这句话是相应的在内存中增加一个单元
而和原来的进行比较是两个单元,所以不同了
this.name = name;
}
function n(name){
this.code = name;
this.a = "gzg";
}
var a= new t("g");
var b= new t("g");
alert(b !== a)
alert(b === a);
alert(b == a);
b = new n("g");
b = "";
alert(b !== a);
非严格相等的匹配原则是啥?
怎么都是true
不是都是TRUE啊
只有
function t(name){
this.name = name;
}
function n(name){
this.code = name;
this.a = "gzg";
}
var a= new t("g");
var b= new t("g");
alert(b !== a)//true
alert(b === a);//false
alert(b == a);//false
b = new n("g");
b = "";
alert(b !== a);//true
因为他们对应的是内存单元不同啊
如果真要比较
java里面比较这种对象用equals()
不知道javascript里可不可以用
不过===好象就是对应的这个
不知道放什么地方去了,把js的一些基本方法重写了一遍