Adding a non-class-syntax method for subclassing native objects

Michael Theriot michael.lee.theriot at gmail.com
Wed May 4 03:01:01 UTC 2016


I believe you can do this with `Reflect.construct`.

```js
function SubArray(arg1) {
  return Reflect.construct(Array, arguments, SubArray);
}
SubArray.prototype = Object.create(Array.prototype);
Reflect.setPrototypeOf(SubArray, Array);

var arr = new SubArray();
arr instanceof SubArray; // true
arr instanceof Array; // true
arr[5] = 0; // should exotically update length property
arr.length === 6; // true
```
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160503/feab3846/attachment-0001.html>


More information about the es-discuss mailing list