Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • This is not a suitable use for Object.create, and won't work this way, too. Commented Aug 4, 2012 at 17:56
  • What is that surrogateConstructor good for, can't you just use the normal one? Or use Object.create(constructor.prototype) if you want to avoid calling it. Commented Aug 4, 2012 at 19:24
  • @Bergi I do want to avoid calling the constructor. However, it's true that it's easier to understand it like that. I have just been used to that way of setting it up since before Object.create existed. That is how developer.mozilla.org/en-US/docs/JavaScript/Reference/… suggests you implement Object.create if it doesn't exist for your browser. Commented Aug 4, 2012 at 19:52
  • Why you did not write "person.prototype= Person.prototype" in your second solution ? Commented Aug 4, 2012 at 20:59
  • @ozz person.prototype does not point to anything. person is an instance of Person. The constructor function Person is the object that contains a .prototype property. Commented Aug 5, 2012 at 21:34