[[Call]] vs. [[Construct]] using symbols

Kevin Smith khs4473 at gmail.com
Sun Oct 7 15:02:09 PDT 2012


> It addresses a common pattern today, that looks like:
>
> function Led( opts ) {
>   if ( !(this instanceof Led) ) {
>     return new Led( opts );
>   }
>
>   // ...
> }
>

Yes - I explored this idea back when we were discussing classes several
months ago.  The thing that you have to consider is that sometimes users
legitimately want to call [[Construct]] to initialize an existing object,
and there needs to be a way to do that.

Kevin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20121007/1b764724/attachment.html>


More information about the es-discuss mailing list