為搞清楚兩者的區別,

參考了別人寫的parseInt&Number的區別:

parseInt Parses a string argument and returns an integer of the specified radix or base. 核心函數 實 " /> 久久理伦片琪琪电影院,宝贝乖女好紧好深好爽老师,日日碰狠狠躁久久躁77777

天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

javascript parseInt與Number函數的區別

但是parseInt("08", 10)是可以返回8的。

為搞清楚兩者的區別,

參考了別人寫的parseInt&Number的區別:

parseInt
Parses a string argument and returns an integer of the specified radix or base.
核心函數
實現版本 Navigator 2.0: If the first character of the string specified in parseInt(string) cannot be converted to a number, returns "NaN" on Solaris and Irix and 0 on all other platforms.Navigator 3.0, LiveWire 2.0: Returns "NaN" on all platforms if the first character of the string specified in parseInt(string) cannot be converted to a number.



語法
parseInt(string,radix)
參數
string A string that represents the value you want to parse.
radix (Optional) An integer that represents the radix of the return value.



描述
The parseInt function is a built-in JavaScript function.
The parseInt function parses its first argument, a string, and attempts to return an integer of the specified radix (base). For example, a radix of 10 indicates to convert to a decimal number, 8 octal, 16 hexadecimal, and so on. For radixes above 10, the letters of the alphabet indicate numerals greater than 9. For example, for hexadecimal numbers (base 16), A through F are used.

If parseInt encounters a character that is not a numeral in the specified radix, it ignores it and all succeeding characters and returns the integer value parsed up to that point. parseInt truncates numbers to integer values.

If the radix is not specified or is specified as 0, JavaScript assumes the following:



If the input string begins with "0x", the radix is 16 (hexadecimal).

If the input string begins with "0", the radix is eight (octal).

If the input string begins with any other value, the radix is 10 (decimal).
If the first character cannot be converted to a number, parseInt returns "NaN".
For arithmetic purposes, the "NaN" value is not a number in any radix. You can call the isNaN function to determine if the result of parseInt is "NaN". If "NaN" is passed on to arithmetic operations, the operation results will also be "NaN".


示例
The following示例 all return 15:
parseInt("F", 16)
parseInt("17", 8)
parseInt("15", 10)
parseInt(15.99, 10)
parseInt("FXX123", 16)
parseInt("1111", 2)
parseInt("15*3", 10) The following示例 all return "NaN":

parseInt("Hello", 8)
parseInt("0x7", 10)
parseInt("FFF", 10) Even though the radix is specified differently, the following示例 all return 17 because the input string begins with "0x".

parseInt("0x11", 16)
parseInt("0x11", 0)
parseInt("0x11")
-----------------------------------------------
-----------------------------------------------
將指定對象轉換為數字。
核心函數
實現版本 Navigator 4.0, NETscape Server 3.0

語法
Number(obj)
參數
obj 一個對象。



描述
如果對象是 Date 類型的對象,Number 將返回自格林威治標準時間 1970 年 1 月 1 日起已經經過的毫秒數,在此日期之后的是正數,之前的是負數。
如果 obj 是一個沒有數字格式的字符串,Number 將返回 NaN。


示例
下面的例子將把 Date 對象轉換為數值型值:
<SCRIPT>
d = new Date ("December 17, 1995 03:24:00");
document.write (Number(d) + "<BR>");

JavaScript技術javascript parseInt與Number函數的區別,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 幻女FREE性俄罗斯学生 | 一级毛片免费视频网站 | 色综合色综合久久综合频道 | 青青草色青伊人 | 欧美ZC0O人与善交的最新章节 | 永久精品免费影院在线观看网站 | 久久超碰国产精品最新 | 男插女高潮一区二区 | 纯肉巨黄H爆粗口男男分卷阅读 | 亚洲乱亚洲乱妇在线观看 | 风情韵味人妻HD | 国产亚洲精品网站在线视频 | 日本伦子欲 | 嫩草影院在线观看网站成人 | 亚洲中文字幕在线第六区 | 四虎国产精品免费观看视频 | 色婷婷五月综合久久中文字幕 | 在线日韩欧美一区二区三区 | 天天狠狠色综合图片区 | 97超碰97资源在线观看 | 国产成人在线视频 | 日本一区精品久久久久影院 | 国产ZZJJZZJJ视频全免费 | 男女后进式猛烈xx00动态图片 | 粗好大用力好深快点漫画 | 美女扒开尿口让男生添动态图 | 无人区乱码1区2区3区网站 | 内地同志男16china16 | 亚洲毛片网 | 日韩高清毛片 | 91国偷自产一区二区三区 | 午夜福利不卡片在线播放免费 | A级毛片无码久久精品免费 a级毛片黄免费a级毛片 | 久久免费视频1 | 一本色道久久综合亚洲精品蜜桃冫 | 亚洲国产成人精品无码区5566 | 中文字幕精品无码一区二区 | 中文字幕亚洲乱码熟女在线 | 国产午夜精品理论片 | 插我一区二区在线观看 | 色琪琪丁香婷婷综合久久 |