小熊奶糖(BearCandy)
小熊奶糖(BearCandy)
发布于 2024-02-26 / 11 阅读
0
0

JavaScript 数据类型转换 及constructor属性

JavaScript 数据类型转换 及constructor属性

Number()转化为数字

String()转化为字符串

Boolean()转化为布尔值

typeof操作符

type"John" 返回string

typeof NaN 返回number

typeof 3.14 返回number

typeof false 返回boolean

typeof [1,2,3,4] 返回object

typeof {name:"jogn"} 返回object

typeof new Date(); 返回object

type of function(){} 返回function

type of myCar 如果myCar未声明变量则返回undefined

typeof null 返回null

constructors属性

屏幕截图 2024-02-26 132913.png

屏幕截图 2024-02-26 133011.png

JavaScript万物皆为对象


评论