1. 基本数据类型的判定:typeof [变量名]
typeof 1 // 'number'
typeof 'string呀' // 'string'
typeof true // 'boolean'
typeof Symbol('abc') // 'symbol'
控制台验证:
扩充知识:typeof NaN // 'number'
。
2. 引用类型 object
的判断: ① constructor ② instanceof ③ Object.prototype.toString.call()
也可以说是数组和对象的区分方法。
var arr=[];//arr.constructor Array
var obj={};//obj.constructor Object
//在控制台输入
arr.constructor
"ƒ Arra