标签:隐式 就是 bool define oat 对象 class parse type
### 显示数据类型的转换
var demo = '123'
demo = Number(demo) //把demo装换为数字
console.log(typeof(demo)) //number
var demoB = true
console.log(Number(demoB)) //1 boolean值转为数字类型以后1为真, 0为假
console.log(Number("sfjafja")) //NaN 不能转为为数字的值转换为数字后, 值为NaN
var demoN = null
console.log(Number(demoN)) //值为0
var demoun = undefined
console.log(Number(demoun)) //NaN
parseFloat(): parseFloat(‘number‘) //用法和parseInt差不多,但是会把所有的数值都转换为浮点数
console.log(parseFloat("100")) //100 整数的时候parseFloat是不会添加.0 de
console.log(parseFloat("100.1")) //100.1
console.log(parseFloat('100.0.01')) //100 默认只会取一个小数点
console.log(parseFloat('100.12raga')) //100.12
var demot = 1213
var demots = toString(demot)
var demounde = toString(undefined)
console.log(typeof (demounde)) //string
console.log(typeof(demots)) //string
标签:隐式 就是 bool define oat 对象 class parse type
原文地址:https://www.cnblogs.com/ghostdot/p/11370844.html