javascriptタイプ変換例
842 ワード
<br> var i="123abc";
<br> i=parseInt(i);//
<br> alert(i+","+typeof(i));// :123,number
<br> i="12.3abc";
<br> i=parseFloat(i);//
<br> alert(i+","+typeof(i));// :12.3,number( int float number )
<br> i="a123abc";
<br> i=parseInt(i);//
<br> alert(i+","+typeof(i));// :NaN,number ( , “ ,Not a Number”)
<br> var num=document.getElementById("num").value;
<br> function showMsg(num)
<br> {
<br> for(var i=0;i<num;i++)
<br> {
<br> document.write(" ,JavaScript!<br/>");
<br> }
<br> }
<br>