JavaScript中如何判断数据类型
如何判断基本类型和引用类型
数据类型
基本类型
- String 字符串
- Number 数值
- Boolean true/false
- Null null
- undefined undefined
引用类型
- Object 任意对象都是Object类型
- Function 一种特别的对象(可以执行)
- Array 数组类型
typeof
typeof返回的是字符串形式的数据类型
typeof判断字符串类型
let a="Vue"
console.log(typeof a);//string
console.log(typeof a==="string");//true
typeof判断布尔型
let a=true
console.log(typeof a);//boolean