I have want to check if an object extends another object (true, false):
Example:
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);
Does underscore.js provide such a function (well I found none…)?
How can I perform such a check?
Try using the
instanceofoperator.