extends null

Marius Gundersen gundersen at gmail.com
Sun Feb 15 23:55:50 PST 2015


>>> The purpose would be defining a class whose instances don't have
Object.prototype on their prototype chain.  If "extends null" doesn't work,
then I think you'd have to do something like this to achieve the same?
>>>
>>>     function NullBase() {}
>>>     NullBase.prototype = Object.create(null);
>>>
>>>     class C extends NullBase {}
>>>

Can't this be solved by returning a null object from the constructor?

```js
class Null{
  constructor() {
    return Object.create(null);
}
}

class MyClass extends Null{

}
let foo = new MyClass();
foo.toString() //ReferenceError
```

Marius Gundersen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150216/d4394b1f/attachment.html>


More information about the es-discuss mailing list