js的数据类型
- js分为基础数据类型和引用数据类型
基础数据类型:String、Number(NaN属于number类型)、Boolean、undefined、Null,symbol
引用类型:Array,Object,function - 类型判断
①、typeof判断,不能精确判断引用类型, typeof(null) // Object
②、NaN == Nav (false)
③、引用类型判断
// 把原型链toString输出方法判断
Object.prototype.toString.call({}) // [object Object]
Object.prototype.toString.call([]) // [object Array]
Object.prototype.toString.call(function a() {}) // [object Function]
Object.prototype.toString.call(null) // [object Null]
// 利用 数组api
Array.isArray([]) // 判断是否为数组
- 所有的引用类型原型都是指向null,原型链表如下图所示