I came here after my paid videos failed to explain me clearly what symbols are, it took me exactly one minute and thirty seconds to understand symbols after starting this video...thanks to youtube for placing the top-notch content on top
Thank you, I had to exit a LinkedIn Learning course and come here to understand it. The content in your channel is amazing, just got yourself a new subscriber. Love from Brazil! ♥
I was confused with the use of Symbols and all of its methods and properties but this quick video helped me to understand what Symbol is. Explained very well. If you can please upload one more video on Symbols explaining its properties and methods? All the stuffs on mozilla reference seems hard to grasp for me. Thanks.
Here is the MDN reference developer.mozilla.org/en-US/docs/Glossary/Symbol They are simply there if you need to have a unique property key for some object. Creating a custom iterator is the most common use.
nullish operators: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-uJ9ylqqDuTI.html ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-onVLVOP7-gI.html Example using Symbol to build a custom iterator - ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-OC9D9REnXPw.html
When you do a for...in loop you are looping through all the key Strings for an object. Symbols are not Strings. So, they do not show up in the list. This is a way that you can create properties inside of an object that are sort-of hidden. If you know the key for the symbol then you can retrieve the Symbol and then access the property of the Object, but it won't appear in the loop. It means you can create unique properties on every object instance that will never conflict with or be overwritten by other properties. There are some built-in properties that use Symbols as their property names. Symbol.iterator is an example - ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-OC9D9REnXPw.html . It does not appear when you do a for loop.
@@SteveGriffith-Prof3ssorSt3v3 Thank you so much for answering my question. I love your channel and you are a teacher to us all. You taught me javascript and I am forever grateful for your teachings :)
Quick question from a Java programmer moving over to learning some JavaScript. Could you explain why console.log() is accessible written just as log()? Thanks in advance!
Hi Sir, Thank you for what you have explained is completely wow but can you please explain me the use cases of symbols and about this meta programming concept a little bit. One more thing can you please explain about the proxy in es6. Thanks in advance.
You can use Symbols as unique ids within objects but the most common thing for them is creating custom iterators. Please add the proxy request to my tutorial request video.
Iterators are definitely the most common. They can be used anywhere you absolutely must have a unique property key. You will also see them in places where you need reference to a unique internal value like with Regular Expressions and the match value. Eg: developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/@@match
When something is being added dynamically to an Object and you have no idea what property names already exist. You need something that is guaranteed to be unique.
If you are referring to the key attribute that you add to React components, then sort of... This code runs key={new Symbol()} But it defeats the purpose of having a unique id that you can refer back to later on to target a component. You should use a unique value that exists in the data.
$ is just one of the possible characters that you can use for a variable name in JavaScript. ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-ILx2rvQDLDk.html
When you need something that is guaranteed to be a unique reference to a property or a method, use a Symbol as the reference. They don't show up when you use for...in or for...of to loop through the properties, but they still exist. Built-in properties and methods sometimes use them too.
U tutor well, however ur display isn't the kind that would catch the fancy of a novice. Tips: u keep to many contents on ur screen per time, u should try dark theme and coloured text, and a bolder screen helps too. Thank u.
You could literally copy another youtubers video that I've watched word for word and I would still understand your lesson better. It would now make sense.
How depends on the app. Why - when you need to add a property with a unique name as to avoid naming conflicts with properties that already exist and ones that will be added in the future.