setPrototypeOf vs obj.__proto__ assignment

Allen Wirfs-Brock allen at
Fri Apr 4 10:49:53 PDT 2014

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 

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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list