我想检查一个对象是否扩展了另一个对象(真,假):

例:

var BaseObject = function(object) {
    this.name = object.name;
    this.someFunction = object.someFunction;
    this.someOtherProperty = object.someOtherProperty;
};

var ExtendingObject = new BaseObject({
    name: "extention",
    someFunction: function(value) { return value; },
    someOtherProperty = "hi"
});

// some possible function
var extends = isExtending(BaseObject, ExtendingObject);
var isParentof = isParentOf(BaseObject, ExtendingObject);

underscore.js是否提供了这样的功能(好吧,我没有发现...)?

我该如何进行检查?

最佳答案

尝试使用 instanceof 运算符。

09-25 18:02