当前位置: 代码迷 >> JavaScript >> javascript中即是(==)与全等(===)的区别说明
  详细解决方案

javascript中即是(==)与全等(===)的区别说明

热度:10308   发布时间:2013-02-26 00:00:00.0
javascript中等于(==)与全等(===)的区别说明

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

?

  相关解决方案