判断对象是否是某个类的实例

判断对象是否是某个类的实例,可以用instanceof运算符,但是不推荐使用

比如var obj = new Date();

obj instanceof Date;//true

obj instanceof Object;//true

obj instanceof Array;//true

推荐使用constructor属性判断

obj.constructor == Date //true

function Test(){}

var tt = new Test();

tt.constructor == Test;//true

原文地址:https://www.cnblogs.com/toward-the-sun/p/4032965.html