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