JavaScript的变量没有类型,能够任意赋值,然而变量的值有类型
根底数据类型
- string
- boolean
- number
- null
- undefined
- symbol
- bigint
援用数据类型
- object
在object类型根底上派生出的援用类型
- Function
- Array
- Date
- 其余
数据类型检测
typeof 检测
typeof "" // string
typeof 1 // number
typeof false // false
typeof Symbol(1) // symbol
typeof BigInt(1) // bigint
var a
typeof a // undefined
typeof null // object, javascript的一个bug
typeof alert // function
typeof 检测其余对象的时候都返回object, 但不是所有typeof 的值为 object的都是对象, null是个很非凡的状况
发表回复