super() on class that extends

Sebastian McKenzie sebmck at gmail.com
Sat Apr 11 02:01:08 UTC 2015


Babel is a terrible reference implementation for subclassing since it relies on the engine. See the docs http://babeljs.io/docs/usage/caveats/#classes and https://github.com/babel/babel/issues/1172 for more info. This exact question (super in derived class constructors) was also indirectly bought up recently in this issue: https://github.com/babel/babel/issues/1131

On Fri, Apr 10, 2015 at 6:57 PM, Garrett Smith <dhtmlkitchen at gmail.com>
wrote:

> On 4/10/15, Axel Rauschmayer <axel at rauschma.de> wrote:
>> The reason why you need to call the super-constructor from a derived class
>> constructor is due to where ES6 allocates instances - they are allocated
>> by/in the base class (this is necessary so that constructors can be
>> subclassed that have exotic instances, e.g. `Array`):
>>
> Can you please explain how extending Array works. Also what is the
> optional identifier optional for in ClassExpression:
> var myArray = (new class B extends Array {
>    constructor() {
>      super(1,2,3,4,5);
>   }
> });
> alert(myArray.length); // it's 0 in Babel.
> -- 
> Garrett
> @xkit
> ChordCycles.com
> garretts.github.io
> personx.tumblr.com
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150410/09780dc2/attachment.html>


More information about the es-discuss mailing list