今天我在做一些实验的时候==
,我无意中发现了这一点"\n\t\r" == 0
。到底如何"\n\t\r"
等于0
,或false
?
我所做的是:
var txt = "\n"; //new line
txt == 0; //it gives me true
这真的让我很恼火。所以我做了更多:
var txt = "\r"; //"return"
txt == 0; //true
var txt = "\t"; //"tab"
txt == 0; //true
这根本没有意义。这是怎么回事?更疯狂的是:
//Checking for variable declared or not
var txt ="\n\t\r";
if(txt!=false){
console.log("Variable is declared.");
}else{
console.log("Variable is not declared.");
}
它给我的是Variable is not declared.
它如何等于0
, 或false
???