转自:nofollow">http://blog.csdn.net/z9061/article/details/7541826
<p align="left" style="color:rgb(51,51,51);font-family:Arial;font-size:14px;"><span style="font-family:'Courier New';font-size:16px;"><span style="line-height:20px;font-size:13px;">ParseInt(<span style="line-height:22px;font-size:14px;">str:String,radix:uint
= 0),<span style="line-height:22px;">将字符串转换为整数。如果参数中指定的字符串不能转换为数字,则此函数返回 NaN。以 0x 开头的字符串被解释为十六进制数字。与 ActionScript 的早期版本不同,以 0 开头的整数不会被解释为八进制数字。必须指定 8 的基数才能解释为八进制数字。有效整数前面的空白和 0 以及后面的非数字字符将被忽略。
<p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;">参数:
<p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;">str:String 要转换为整数的字符串
<p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;">radix:uint (default = 0) — 表示要分析的数字的基数(基)的整数。合法值为 2 到 36。
<p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;"><span style="color:rgb(51,102,255);">即被解析的字符串本身属于哪种类型的数据,二进制,八进制....
<p align="left" style="color:rgb(51,255);">例如要将二进制数100101110转换为整数,就要这样写<span style="color:rgb(51,153,102);">parseInt("<span style="color:rgb(255,0);">100101110",<span style="color:rgb(255,0);">2)
<p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;"><span style="font-family:'Courier New';font-size:16px;"><span style="line-height:20px;font-size:13px;">
<p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;"><span style="font-family:'Courier New';font-size:16px;"><span style="line-height:20px;font-size:13px;">输出:
<p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;">
<span style="color:rgb(51,51);font-family:'Courier New';font-size:16px;"><span style="color:rgb(51,51);font-family:Arial;font-size:14px;">
<p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;">parseInt("ABC")=NaN
<p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;">parseInt("123.0123")=123
<p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;"><span style="color:rgb(255,0);">parseInt(" a456")=NaN
<p align="left" style="color:rgb(51,0);">parseInt("456b123")=456
<p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;">parseInt(" 789 ")=789
<p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;">
<p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;">int("ABC")=0
<p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;">int("123.0123")=123
<p align="left" style="color:rgb(51,0);">int(" a456")=0 <span style="color:rgb(51,102);">如果要转换的是非有效字符串,则返回0
<p align="left" style="color:rgb(51,0);">int("456b123")=0
<p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;">int(" 789 ")=789
<p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;">parseInt("123")=123
<p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;">parseInt("0123")=123
<p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;">parseInt("0x123")=291 <span style="color:rgb(51,102);">将十六进制数0x123转换为整数就是29<span style="color:rgb(51,102);">1
<p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;">parseInt("100101110",2)=302 <span style="color:rgb(51,102);">将二进制数“100101110”转换为整数就是302
<p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;">parseInt("100",8)=64
<p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;">parseInt("123",10)=123
<p align="left" style="color:rgb(51,51);font-family:Arial;font-size:14px;">parseInt("263a",16)=9786