3 ms·
p2 is not an instance of Person. You also need to make sure p2's constructor is set to Person.
by dskloet 10y ago
p2 is not an instance of Person. You also need to make sure p2's constructor is set to Person.
- gurgus 10y agoInteresting - how can I go about this?
- dskloet 10y agop2.constructor = Person; Without that, the object also doesn't have the right prototype.
- gurgus 10y agoThanks! Will update my post and attribute you with that!
- gurgus 10y agoAll fixed up now. Thanks for the feedback :) I ended up setting __proto__ directly so that an instanceof test passes.
- dskloet 10y agoLooks like that didn't work either and you ended up with Object.create which is a fairly new function. I think assigning Person.prototype (instead of Person) to p2.__proto__ would have worked. Or is that already what you had before?