They are no necessary the same:

```js
var _Object = window.Object,
    Object = function() {};
class Foo1 {
  constructor() {}
}
class Foo2 extends Object {
  constructor() { super(); }
}
_Object.getPrototypeOf(Foo1.prototype); // _Object.prototype
_Object.getPrototypeOf(Foo2.prototype); // Object.prototype
```

You are able to shadow or replace `Object` with a custom constructor. And this 
constructor might use `this`, that's why `super()` is required.

> From: [email protected]
> Date: Sat, 23 Apr 2016 18:15:28 -0700
> Subject: Extending Object
> To: [email protected]
> 
> Are the following examples the same? Is there any reason to extend
> Object manually?
> 
> ```js
> class Foo {
>   constructor() {}
> }
> new Foo
> ```
> 
> ```js
> class Foo extends Object {
>   constructor() { super() } // super() is required.
> }
> new Foo
> ```
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
                                          
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to