Hi, I think you should je return whaterver is returned by the constructor.
And typeof {}==='object' All lowercase Your second call should be apply And constructor isn't a property of instances, it is a property of the prototype if i remember welll. I'll post an implementation later if noone else does it because atm, i'm on my mobile phone. On Jul 15, 2011 1:09 PM, "Shreyas Subramaniam" < shreyas.subraman...@burrp.com> wrote: > Hi > > Just as an exercise, I tried an implementation of the "new" operator. Is > this complete? Is there anything else happening under the hood? > > *var instanceMaker = function(f) { > ** var obj = {}; > ** obj.constructor = f; > ** obj.__proto__ = f.prototype; > ** var argArray = Array.prototype.slice.call(arguments,1); > ** var returnObj = f.call(obj,argArray); > ** if (returnObj && (typeof returnObj === "Object")) { > ** return returnObj; > ** } else { > ** return obj; > ** } > **};* > * > * > * > * > * > * > Regards, > Shreyas > > -- > 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 -- 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