用于检验构造函数的prototype属性是否出现在对象的原型链中的任何位置
let a = [];
a instanceof Array; //true
let b = {};
b instanceof Array; //false
在上方代码中,instanceof运算符检测Array.prototype属性是否存在于变量a的原型链上,显然a是一个数组,拥有Array.prototype属性,所以为true。
实例的构造函数属性constructor指向构造函数,那么通过constructor属性也可以判断是否为一个数组。
let a = [1,3,4];
a.constructor === Array;//true
console.log(Object.prototype.toString.call([]));//{object Array}
$.type(null) // {object Null}
$.type([]) // {object Array}
let a = [1,2,3]
Array.isArray(a);//true
原文:https://www.cnblogs.com/33shan/p/14264476.html