new instantiation design alternatives

Domenic Denicola domenic at domenicdenicola.com
Thu Sep 18 13:30:44 PDT 2014


From: Allen Wirfs-Brock [mailto:allen at wirfs-brock.com] 

> But that won't give you a real HTMLElement exotic object, if there is such a thing, and won't initialize it properly.
>
> But you can get around that problem if the HTMLElement constructor is defined appropriately using this^:

That's a good point, thanks for explaining. (I assume you mean `new^`? You keep saying `this^` here and in other messages so I wonder if you've had a shift in thinking.)

At this point my only real argument for implicit `this = Object.create(new^.prototype)` is that it's what happens with function-based inheritance. I agree with Dmitry that there probably is no good default so I guess I just find taking cues from what functions do to be the best guidance. But requiring explicit initialization seems fine too.


More information about the es-discuss mailing list