日期:2014-05-16 浏览次数:20494 次
<script src="Person.js"></script> <div id="disp"></div> <script language="JavaScript"> var unde; var toCheckArray=new Array(7); toCheckArray[0]=null; toCheckArray[1]=unde; toCheckArray[2]=""; toCheckArray[3]=0; toCheckArray[4]="a"; toCheckArray[5]="0"; toCheckArray[6]=1; for(var e in toCheckArray){ console.log("value=" + toCheckArray[e] + " <--> " + (toCheckArray[e]?true:false)+" type= " + typeof(toCheckArray[e])); } var output=""; output+="var unde;</br>"; output+= ' toCheckArray[0]=null; '+' </br> ' ; output+= ' toCheckArray[1]=unde; '+' </br> ' ; output+= ' toCheckArray[2]=""; '+' </br> ' ; output+= ' toCheckArray[3]=0; '+' </br> ' ; output+= ' '+' </br> ' ; output+= ' toCheckArray[4]="a"; '+' </br> ' ; output+= ' toCheckArray[5]="0"; '+' </br> ' ; output+= ' toCheckArray[6]=1; '+' </br> ' ; alert(output); output +="<table border=1>"; output +=" <TR> <TD>值</TD> <TD>转化为布尔型 </TD> <TD>typeof</TD> </TR>"; for(var e in toCheckArray){ output +="<tr>"; output +="<td> toCheckArray[" + e + "]: value=" + toCheckArray[e] + "</td> <td>if(value)==" + (toCheckArray[e]?true:false)+"</td> <td>typeof== " + typeof(toCheckArray[e])+"</td>"; output +="</tr>"; } output+="</table>"; var divTag = document.getElementById("disp"); divTag.innerHTML=output; </script>?