extends null

Erik Arvidsson erik.arvidsson at gmail.com
Mon Feb 16 06:07:06 PST 2015


No that would not work either. You want an object that has its
[[Prototype]] set to MyClass.prototype.

On Mon, Feb 16, 2015, 02:55 Marius Gundersen <gundersen at gmail.com> wrote:

> >>> 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/63a4698a/attachment.html>


More information about the es-discuss mailing list