instanceof

使用instanceof可以判断函数是否是一个变量的构造函数,如使用instanceof可以判断一个变量是否是array类型

1 var arr=[1,2,3];
2 arr instanceof Array;//true
3 typeof arr;//object  而typeof只能判断它是对象

instanceof的判断的原理就是:

沿着原型链去找这个对象的__proto__属性值是否与构造函数的prototype属性值相同

1 arr instanceof Object;//true
原文地址:https://www.cnblogs.com/cherryshuang/p/8505960.html