值类型(基本类型): 字符串(string)、数字(Number)、布尔(Boolean)、对空(Null)、未定义(Undefined)、Symbol
引用数据类型: 对象(Object)、数组(Array)、函数(Function)
注: Symbol 是ES6 引入了一种新的原始数据类型,表示独一无二的值
typeof 123 // "Number"
typeof 'abc' // "String"
typeof true // "Boolean"
typeof undefined // "undefined"
typeof null // "object"
typeof {
} // "object"
typeof [] // "object"
typeof typeof null // "string"
typeof console.log() // "function"
null instanceof Object // false
typeof
与 instanceof
的区别
typeof: 它返回值是一个字符串,该字符串说明运算数的类型
instanceof:
语法:object instanceof constructor
instanceof运算符用来检测 constructor.prototype 是否存在于参数 object 的原型链上