<div class="htmlarea"> <textarea id="runcode7897"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <script type="text/javascript"> var y = 5; if(y == "5"){ document.write("== '5' True "); } else{ document.write("== '5' False "); } if(y == 5){ document.write("== 5 数字 is True "); } else{ document.write("== 5 数字 False "); } if( y === 5){ document.write("=== 数字5 is True "); } else{ document.write("=== 数字5 False "); } if(y === "5"){ document.write("=== 5 is True "); } else{ document.write("=== 5 is False "); } </script> </textarea><br><input onclick="runEx('runcode7897')" type="button" value="运行代码"> <input onclick="doCopy('runcode7897')" type="button" value="复制代码"> <input onclick="doSave(runcode7897)" type="button" value="保存代码">[Ctrl+A 全选 注:<a href="http://www.jb51.net/article/23421.htm" title="查看具体详情" target="_blank">如需引入外部Js需刷新才能执行</a>]</div> <br>从以上代码可以看出,等于(==)的情况下 只要值相同就返回True。而全等(===)的时候需要值和类型都要匹配才能返回True, <br>