1. 程式人生 > >Js parsetInt() 字符串轉換,只能轉換字符串,數字開頭的才會返回數值,否則為NaN,空字符串也返回NaN

Js parsetInt() 字符串轉換,只能轉換字符串,數字開頭的才會返回數值,否則為NaN,空字符串也返回NaN

gpo 字符串 開頭 col color OS 轉換 class 字符串轉換

            alert(parseInt(456lee));   //456,返回正數部分
            alert(parseInt(lee456lee));   //NaN
            alert(parseInt(lee456lee));   //NaN
            alert(parseInt(‘‘));            //NaN

Js parsetInt() 字符串轉換,只能轉換字符串,數字開頭的才會返回數值,否則為NaN,空字符串也返回NaN