On Fri, Jul 15, 2011 at 1:38 PM, Xavier MONTILLET <xavierm02....@gmail.com> wrote: > Hi, > > I think you should je return whaterver is returned by the constructor.
Nah, construtors always return an object. If you don't (ie. `return 5;`), the original new instance is returned anyways. I would suggest you use a blacklist for primitives with typeof though, since host objects and function do not (have to) return "object". And also check for null, since that returns "object" as well. For future proofing, also check if typeof returns "null", because that will be fixed later. Other than that, yeah looks fine. Important part is fixing the [[Prototype]] reference. Maybe you could create the new object with Object.create so that it works in all es5 compliant browsers? I wouldn't rely on __proto__ too much. Maybe try to fall back to __proto__ if Object.create does not exist. - peter -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/jsmentors@jsmentors.com/ To search via a non-Google archive, visit here: http://www.mail-archive.com/jsmentors@googlegroups.com/ To unsubscribe from this group, send email to jsmentors+unsubscr...@googlegroups.com