Symbols - Javascript In Depth
HTML-код
- Опубликовано: 4 авг 2024
- We take a look at Symbols in Javascript together. These are a primitive type that are guaranteed to be unique and most commonly used inside of Object properties as keys. We look at some well-known Symbols like Symbol.iterator and how we can use it with Generators to iterate over custom Objects.
This is part of a series where we go over Javascript in depth to learn programming concepts as well as web development: • Javascript In Depth
Chapters:
00:00 Introduction
00:45 Primitives Recap
01:53 What are Symbols?
03:37 Creating a Symbol
05:46 Symbols Code Example
10:00 "Special" Property Keys
10:59 "Special" Object Keys Code Example
15:11 Symbols as Object Keys
16:56 Symbols as Object Keys Code Example
20:14 Well-known Symbols
23:25 Symbol.iterator Object Key
27:05 Next Steps
📦 Github Repository with the notes and exercise code+solutions: github.com/Nooder/javascript-...
💬 Come join us on Discord to chat with a like-minded community about tech and learning: / discord
🏅Support the channel and content through Super Thanks, Channel Memberships, or on Patreon: / techwithnader Наука
Excited to see this used in action as we move forward 👍🏼
They will pop up all over the place even when we don’t use them explicitly 😉
Excellent video, thank you. I'm sure Symbols could be useful to me; I'm just not sure how, yet.
only thing i'd kind of disagree with is null and undefined are not semantically the same thing and it is useful to have both. Null is a value of 'nothing'. As in, the variable has been declared and assigned a value, but that value, itself, is nothing. Undefined indicates the variable has been declared but no value has been assigned to it, yet. Like people waiting in a line at the bank to see how much is in their account - all the people are variables that have been declared but nothing's happened with them, yet. They are in an undefined state and haven't been processed, yet. As each person goes to the teller, the teller lets them know what their account balance is. Some might have 100 bucks, some might have 0 dollars, but they all have a value assigned. Then someone comes up to the window and the teller says, "you don't have an account with us". They don't even have 0, they just don't have an account - but it's still a valid state. That would be null.
Buuut since that's not really the content being covered, I'll say thanks for the video, it really helped. Subscribing, thanks!
This is awesome, never knew this
It’s definitely a less taught and studied feature, so I’m glad you found it interesting and useful! 😊
looking forward to see the use of symbols in Class
A small doubt for me , in 18:55 why 9 is printed first , as it was in the last in the object
Good catch! I am also curious about it. Could you please clarify @TechWithNader