`Object.getPrototypeOf` and `Object.setPrototypeOf` works everywhere,
including null objects, as long as extension hasn't been prevented (
`Objet.freeze`, `Object.seal` or `Object.preventExtension` )

It's `__proto__` accessor that indeed doesn't work as expected in null
object, where it's always stored as key.

```js
var dict = Object.create(null);
dict.__proto__ = [];

Object.keys(dict); // ["__proto__"]
dict instanceof Array; // false

Object.setPrototypeOf(dict, []);
dict instanceof Array; // true
```

However, if you want the key `"__proto__"` you can specify it at string at
runtime `{"__proto__": "this way"}` or use `Object.defineProperty(obj,
"__proto__", {value: "any"})`

Regards



On Tue, Feb 16, 2016 at 5:47 AM, JD Isaacks <[email protected]> wrote:

> > Object.getPrototypeOf and Object.setPrototypeOf are the "no-dunder"
> ways to do it.
>
> Not if you are trying to set in an object literal.
>
> On Tue, Feb 16, 2016 at 12:17 AM, Kevin Smith <[email protected]>
> wrote:
>
>> Is there a migration to make it a Symbol in ES7?  (ignorant question?)
>>>
>>
>> Object.getPrototypeOf and Object.setPrototypeOf are the "no-dunder" ways
>> to do it.
>>
>>
>>
>
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to