Any reason why __proto__ is not a well known symbol?
Andrea Giammarchi
andrea.giammarchi at gmail.com
Wed Feb 17 00:34:51 UTC 2016
You break an open door and I was the one proposing `setPrototypeOf` and to
kill `__proto__` long time ago but about this:
> Don't teach people that `__proto__` is a magical property - it is not
(causing confusion); and they only will start or continue using it in new
code.
I'm afraid my recent book is the only one I know that avoided dunder-proto.
Most other articles/books about "modern JS" all use and/or describe
`__proto__`
So we need people to stop using it, and modules would be a great
opportunity to at least warn the community, and we need to stop talking
about it in modern published online and offline books.
Best Regards
On Tue, Feb 16, 2016 at 9:00 PM, Bergi <a.d.bergi at web.de> wrote:
> Andrea Giammarchi wrote:
>
> As much as Id love to see dunder-`__proto__` burn away from any future
>> specification,
>>
>
> Before doing that, we should burn it away from everyones code :-)
>
> there are at least two use cases I do like in terms of
>> simplification:
>>
>> 1. to shortcut literals with enumerable, configurable, and writable
>> own
>> properties that extend known objects (or null) such `{__proto__:null,
>> key:
>> 'value'}` . This cannot be compared with the tedious
>> `Object.create(null,
>> {key: {enumerable: true, writable: true, configurable: true, value:
>> 'value'}})`
>>
>
> The much simpler solution to that would be `Object.setPrototypeOf({key:
> 'value'}, null)` (which also returns the object). Admittedly, putting the
> prototype in the end is a bit awkward, and `__proto__` in a literal
> probably simplifies creation optimisations.
> The way to overcome this would be to promote the [prototype `<|` operator](
> http://wiki.ecmascript.org/doku.php?id=harmony:proto_operator), which I
> would love to see in ES8. Anyone up for making an up-to-date proposal?
>
> 2. to explain inheritance through the console or to people in general,
>> using it only as virtual-read-only reference to the inheritance chain
>>
>
> I wholeheartedly recommend to use the term *[[prototype]]* (in italics or
> color) for this, and call it out as what it is: an **internal** property.
> Don't teach people that `__proto__` is a magical property - it is not
> (causing confusion); and they only will start or continue using it in new
> code.
> Even in code examples, or simple demonstrations, use `console.log(x,
> Object.getPrototypeOf(x))` over `console.log(x, x.__proto__)`.
>
> Regards,
> Bergi
>
> PS: Ceterum censeo __proto__ esse delendum :-)
>
> _______________________________________________
> 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/20160217/f1f256bf/attachment-0001.html>
More information about the es-discuss
mailing list