6 comments

[ 3.0 ms ] story [ 29.2 ms ] thread
p2 is not an instance of Person. You also need to make sure p2's constructor is set to Person.
Interesting - how can I go about this?
p2.constructor = Person;

Without that, the object also doesn't have the right prototype.

Thanks! Will update my post and attribute you with that!
All fixed up now. Thanks for the feedback :) I ended up setting __proto__ directly so that an instanceof test passes.
Looks 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?