I'm working on a JavaScript and I got stuck with some verification :
I'd like to check that the variable given as a parameter was an instance of an instance of an object. To be more clear, here's an example :
var Example = function () {
console.log ('Meta constructor');
return function () {
console.log ('Instance of the instance !');
};
};
var inst = new Example();
assertTrue(inst instanceof Example.constructor); // ok
var subInst = new inst();
assertTrue(subInst instanceof Example.constructor); // FAIL
assertTrue(subinst instanceof inst.constructor); // FAIL
How can I check that subInst
is an instance of Example.{new}
? or inst.constructor
?