super() on class that extends
Allen Wirfs-Brock
allen at wirfs-brock.com
Sat Apr 11 02:54:31 UTC 2015
> On Apr 10, 2015, at 10:29 PM, Axel Rauschmayer <axel at rauschma.de> wrote:
>
> No engine has implemented subclassing of `Array`, yet: http://kangax.github.io/compat-table/es6/#Array_is_subclassable <http://kangax.github.io/compat-table/es6/#Array_is_subclassable>
>
> And, as Sebastian mentioned, you can’t transpile it, because it depends on the cooperation of `Array`: it becomes the base constructor and allocates an exotic array instance (with special handling for `length` etc.) whose prototype is `new.target`.
note totally true:
```js
class SubArray extends Array {
constructor(…args) {
let newObj = new Array(…args);
newObj.__proto__ = SubArray.prototype; //or new.target.prototype
return newObj
}
subclassMethiod() {}
}
```
Allen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150410/d78d6821/attachment.html>
More information about the es-discuss
mailing list