判断数据类型的方法有四种,分别是:typeof、instanceof、constructor、toString()
typeof 一般是用于判断基本的数据类型,但是null除外,因为 typeof null 输出的是object
instanceof 一般用于判断引用的数据类型,最常用的 [] instanceof Array 判断是否是数组 isArray()
constructor 基本都可以判断 除了undefined 和 null ({}).constructor==Object
toString() 全能 所有的数据类型都可以判断 Object.prototype.toString.call({})