javascript中等于(==)与全等(===)的区别说明
?
等于(==)的情况下 只要值相同就返回True。而全等(===)的时候需要值和类型都要匹配才能返回True.
?
?
?
<script type="text/javascript">?
? ?function ?ff(){
var y = 5;?
if(y == "5"){?
document.write("1== '5' True ");?
}?
else{?
document.write("== '5' False ");?
}?
if(y == 5){?
document.write("12== 5 数字 is True ");?
}?
else{?
document.write("== 5 数字 False ");?
}?
if( y === 5){?
document.write("13=== 数字5 is True ");?
}?
else{?
document.write("=== 数字5 False ");?
}?
if(y === "5"){?
document.write("=== 5 is True ");?
}?
else{?
document.write("14=== 5 is False");?
}?
}
?
</script>
?
t
t
t
f
?