Blogger Information
Blog 7
fans 0
comment 0
visits 4643
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
独孤九贱 JavaScript 笔记(四) —— 转换数据类型
残羽的博客
Original
613 people have browsed it

Number()

概念:

其它类型专属值类型

总结:

适用于任何类型转换为数值型

parseInt()

概念:

将数字开头的字符串转为整数

总结:

适合于有前导整数类型数字的非空字符串

parseFloat()

概念:

将数字开头的字符串转为小数

总结:

适合于有前导小数类型数字的非空字符串


例子:

> Number('')
< 0

> Number('1234')
< 1234

> Number(true)
< 1

> Number('JavaScript')
< NaN    /*不是有效数值*/

> Number('1234JavaScript')
< NaN

> parseInt('1234php')
< 1234

> parseInt('12.34php')
< 12

< parseFloat('12.34php')
< 12.34


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments