Extending Object
# Oriol Bugzilla (10 years ago)
They are not necessarily the same:
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.
# Allen Wirfs-Brock (10 years ago)
An HTML attachment was scrubbed... URL: esdiscuss/attachments/20160423/004fe620/attachment
Are the following examples the same? Is there any reason to extend Object manually?
class Foo { constructor() {} } new Fooclass Foo extends Object { constructor() { super() } // super() is required. } new FooAre 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 ```