JavaScript Symbols - HTTP203

preview_player
Показать описание
Jake Archibald explains JavaScript Symbols to Surma in 2 minutes. What do you use them for!? Why!? All will be revealed... #HTTP203

Рекомендации по теме
Комментарии
Автор

It will be great if you guys will show a "real world" implementation examples of what you're explaining!

noidar
Автор

As a newer developer, I feel that these type of videos would be way more useful with live code examples, rather than just strict conversation. I realize that the point may be to have your audience go and research on their own, but in the moment being able to see an example would be more helpful in my opinion.

LGND-cmro
Автор

JavaScript Symbols! What do you use them for? Do you use them for anything? Let's find out!

squirrelmanish
Автор

I'm a super fan of #HTTP203. You are my favorite youtubers. 👍

fabiocroldan
Автор

Guys, you are doing great and thanks for uploading these videos. if possible, could you pls add few code examples with the dicussion.

praveenX
Автор

I'd like to watch something about proxies soon!

Era
Автор

So it's all going to change soon. What a surprise.

MartinHodgkins
Автор

Anyone have more information regarding Symbols across iframes?

qabandiman
Автор

I've always felt that Symbols were most useful with "native" (well-known) ones, like Symbol.iterator as you mentioned.
For the rest, I still have to find a solid use case.
Non-enumerable properties? Object.defineProperty got us covered.
Private properties? Not really, since we have Object.getOwnPropertySymbols and Reflect.ownKeys.
Moreover, symbols aren't really polyfillable, so you can't use them if you have to support IE.
Does anyone have any experience with symbols outside the well-known ones?

MaxArt
Автор

I would like a medium Fries and a double Cheese Burger. Thank you

trappedcat
Автор

Symbols are hidden not because they are not enumerable, but since from es2015 keys now are divided into 2 categories:

1. names
2. symbols

So all the methods that already existed by then only take into account names. There is a big problem with nomenclature, since some old method names use "key" or "keys" but it's no longer correct.


> When the keys function is called with argument O, the following steps are taken:
>
> 1. Let obj be ? ToObject(O).
> 2. Let nameList be ? EnumerableOwnNames(obj).
> 3. Return
>
> If an implementation defines a specific order of enumeration for the for-in statement, the same order must be used for the elements of the array returned in step 3.


> When the abstract operation EnumerableOwnNames is called with Object O, the following steps are taken:
>
> 1. Assert: Type(O) is Object.
> 2. Let ownKeys be ? O.[[OwnPropertyKeys]]().
> 3. Let names be a new empty List.
> 4. Repeat, for each element key of ownKeys in List order
> a. If Type(key) is String, then
> i. Let desc be ? O.[[GetOwnProperty]](key).
> ii. If desc is not undefined, then
> 1. If desc.[[Enumerable]] is true, append key to names.
> 5. Order the elements of names so they are in the same relative order as would be produced by the Iterator that would be returned if the EnumerateObjectProperties internal method was invoked with O.
> 6. Return names.

So as we can see here, there one main concept: keys, which they can be symbols, or names (strings), and Object.keys, and a lot of methods from es5 and below use EnumerableOwnNames algorithm to get the names (not well named "keys").

TL;DR
No matter that both are keys, symbols shouldn't be confused with names, since these last ones are strings, so we have to check from the spec the method that we would like to use to see what considers to be a key, if it's talking about names (strings) or symbols.

MauroGabrielTitimoli
Автор

It always felt like a worse supported weakmap to me.

Pesthuf
join shbcf.ru