Making Object Literals a sub-class of Object
a.d.bergi at web.de
Fri Oct 14 13:24:38 UTC 2016
Brian Ninni wrote:
> On more than one occasion I've had to determine whether something was a
> plain old Object, or some other class. This involves checking that the
> given object was NOT an instanceof any other acceptable class.
`Object.prototype.isPrototypeOf(o)` should do that (if you don't care
about other realms).
> Array, RegExp, Function, and Class Literals all already create an Object
> sub-class, so why not Object Literals?
Because Object-objects are just Objects and not anything special that
would need a subclass with specific methods.
> Are there any other major reasons why this is a bad idea?
As you already said, it would break a great lot of code.
More information about the es-discuss