Re: Making Object Literals a sub-class of Object

2016-10-14 Thread Rick Waldron
On Fri, Oct 14, 2016 at 9:05 AM Brian Ninni wrote: > I did a quick search and didn't find any recent mentions of this topic. > > 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

Re: Making Object Literals a sub-class of Object

2016-10-14 Thread Oriol Bugzilla
Object literals (object initializers) are just a convenient way to create a new ordinary object which (initially) inherits from `Object.prototype`, and populate it with some properties. I don't think you should be able to distinguish them from similar objects not created using object initialize

Re: Making Object Literals a sub-class of Object

2016-10-14 Thread Brian Ninni
> > `({}).toString.call(o);` This does work for all Native class, but still returns "[object Object] " for user created classes `Object.getPrototypeOf({}) === Object.prototype // true` Did not know of that method. Seems like a roundabout way, but it works. `Object.prototype.isPrototypeOf(o)`

Re: Making Object Literals a sub-class of Object

2016-10-14 Thread Bergi
I wrote: 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

Re: Making Object Literals a sub-class of Object

2016-10-14 Thread Bergi
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

Re: Making Object Literals a sub-class of Object

2016-10-14 Thread Guylian Cox
If you want to check that your variable is a plain old object and not some other class, you can use `Object.getPrototypeOf(x) === Object.prototype` `Object.getPrototypeOf({}) === Object.prototype // true` `Object.getPrototypeOf(new Map()) === Object.prototype // false` Le ven. 14 oct. 2016 à 15

Re: Making Object Literals a sub-class of Object

2016-10-14 Thread Petter Envall
2016-10-14 15:05 GMT+02:00 Brian Ninni : > I did a quick search and didn't find any recent mentions of this topic. > > 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 instance