1、typeof操作符是用来检测数据类型的,但是只能准确检测基本数据类型,检测引用类型的值不准确
typeof 数字 返回 “number” typeof 字符串 返回 “string”
typeof undefined 返回 “undefined”
typeof null/数组/对象 都返回 “object
特别 typeof 函数 返回 “function” typeof 正则表达式 根据浏览器的版本不同,会返回 “function”或者"object"
2、instanceof操作符也是用来检测数据类型的,但是只能用来检测引用类型数据,如果检测基本类型数据,始终都是返回false;
对象 instanceof Object 返回 true 数组 instanceof Array 返回true