setPrototypeOf vs obj.__proto__ assignment

Andrea Giammarchi andrea.giammarchi at gmail.com
Fri Apr 4 11:01:02 PDT 2014


you probably meant this link too?
http://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.setprototypeof


   1. If Type<http://people.mozilla.org/~jorendorff/es6-draft.html#sec-ecmascript-data-types-and-values>
   (*proto*) is *neither Object nor Null*, then throw a *TypeError*
    exception.

Best Regards


On Fri, Apr 4, 2014 at 10:49 AM, Allen Wirfs-Brock <allen at wirfs-brock.com>wrote:

>
> On Apr 4, 2014, at 10:22 AM, John Barton wrote:
>
> I was surprised to discover that in chrome at least this is valid:
>   var obj = {};
>   obj.__proto__ = undefined;
> but this throws
>    Object.setPrototypeOf(obj, undefined);
>
> Is it intended?
>
>
> Yes,  see the spec at
> http://people.mozilla.org/~jorendorff/es6-draft.html#sec-set-object.prototype.__proto__
>
>
> It's that way because that's how __proto__ has always worked.
>
> __proto__ is there for legacy compatibility.
> setPrototypeOf should be preferred for new code
>
> Allen
>
> _______________________________________________
> 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/20140404/11688ddb/attachment.html>


More information about the es-discuss mailing list