I have two classes:
class Bar extends Foo { // Foo isn\'t relevant constructor(value) { if (!(value instanceof Foo)) throw \"InvalidArgumentException:
Check the constructor:
if (!value || value.constructor !== Foo) throw 'InvalidArgumentException: (...)';
or the prototype of the object (this is more similar to what instanceof does):
instanceof
if (!value || Object.getPrototypeOf(value) !== Foo.prototype) throw 'InvalidArgumentException: (...)';