A Precedent

Andrea Giammarchi andrea.giammarchi at gmail.com
Sun Apr 14 22:09:20 PDT 2013


at least in Firefox is working like that:

var blackMagic = Object.getOwnPropertyDescriptor(
  Object.prototype, '__proto__'
).set;

var NaO = Object.create(null);

var o = {};

blackMagic.call(NaO, o);

o.isPrototypeOf(NaO); // true

if this will work cross browser like this adopting a method rather than a
property that who knows if it'se there or not seems to be a natural
consequence, same way almost every library I know use

var hasOP = {}.hasOwnProperty

then hasOP.call(obj, prop)
 so even Object.create(null) can be checked like that

Best Regards







On Sun, Apr 14, 2013 at 9:23 PM, Nathan Wall <nathan.wall at live.com> wrote:

> Brendan Eich wrote:
> > ...
> https://mail.mozilla.org/pipermail/es-discuss/2013-February/028631.html
> >
> > It looks like the setter throws only if called on an object from a
> > different "realm", so maybe it will work for your intended uses. It
> > won't work cross-frame, in other words.
> >
> > /be
>
> Great!  Will the setter be capable of setting the prototype on objects
> which don't inherit from `Object.prototype` (as long as they're in the same
> realm)?  If so, that would allow me to work around the majority of my
> problems from [1].  There are still some edge cases that couldn't be
> supported, but I'll be okay with that since they are really minor edge
> cases.
>
> [1] https://mail.mozilla.org/pipermail/es-discuss/2013-March/029329.html
>
> Nathan
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130414/f142ed55/attachment.html>


More information about the es-discuss mailing list