
Creating a JavaScript object without the new keyword - gurgus
http://www.davecooper.org/creating-a-javascript-object-without-new
======
dskloet
p2 is not an instance of Person. You also need to make sure p2's constructor
is set to Person.

~~~
gurgus
Interesting - how can I go about this?

~~~
dskloet
p2.constructor = Person;

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

~~~
gurgus
All fixed up now. Thanks for the feedback :) I ended up setting __proto__
directly so that an instanceof test passes.

~~~
dskloet
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?

