Intro to JavaScript Symbols

แชร์
ฝัง
  • เผยแพร่เมื่อ 8 ก.ค. 2018
  • ES6 introduced a new type of Primitive value - Symbols.
    This tutorial covers what exactly Symbols are and how you can manage them.
    Code GIST: gist.github.com/prof3ssorSt3v...

ความคิดเห็น • 58

  • @TS-rw5hw
    @TS-rw5hw 3 ปีที่แล้ว +1

    The days that I haven't found this channel is wasted.

  • @dpradeepc
    @dpradeepc 5 ปีที่แล้ว +4

    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

  • @abhijeethycinth
    @abhijeethycinth 5 ปีที่แล้ว +9

    This explanation touches almost every aspect of Symbols. Thank you very much. One of the best explanations out there.

  • @arunjaiswal8650
    @arunjaiswal8650 ปีที่แล้ว

    It's really an amazing experience to watch this video about symbols

  • @skan90
    @skan90 ปีที่แล้ว +1

    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! ♥

  • @pk_2cents696
    @pk_2cents696 5 ปีที่แล้ว +1

    Thank you so much. I could not find the proper explanation for symbols anywhere and got here ,you explained it pretty well

  • @nitsanbh
    @nitsanbh 3 ปีที่แล้ว +1

    Your voice cures my soul

  • @rotrose7531
    @rotrose7531 4 ปีที่แล้ว

    Thank you for another excellent and well-explained tutorial.

  • @ahmedkhalid-ld1ex
    @ahmedkhalid-ld1ex 2 ปีที่แล้ว

    Best explanation i could find so far, thanks a lot for your effort ♥️

  • @_isaac_muniz_
    @_isaac_muniz_ 3 ปีที่แล้ว

    It is the best video I found about Symbols! Nice work!

  • @farhan787
    @farhan787 5 ปีที่แล้ว +2

    Thanks a ton Steve, it was really helpful.

  • @chesterxp508
    @chesterxp508 2 ปีที่แล้ว

    Another very cool tutorial!

  • @rakesh.rankawat
    @rakesh.rankawat 3 ปีที่แล้ว

    You solve my whole pain... Thanks man!

  • @divya101993
    @divya101993 5 ปีที่แล้ว

    Symbols well explained, thanks for the video !!

  • @rungekutta5732
    @rungekutta5732 4 ปีที่แล้ว

    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.

  • @becauseistand
    @becauseistand 5 ปีที่แล้ว

    brilliant explanation.
    thanks a lot!

  • @Videosuser
    @Videosuser 2 ปีที่แล้ว

    Thank you very much. One of the best explanations out there. 2

  • @norbertolkowski6285
    @norbertolkowski6285 4 หลายเดือนก่อน +1

    Good video :D. Thank you so much

  • @davidascholer
    @davidascholer 3 ปีที่แล้ว

    Best video on Symbols 👍

  • @pratham5746
    @pratham5746 4 ปีที่แล้ว

    Thank u so much I learned the symbol by 1 vid

  • @warrent8590
    @warrent8590 5 ปีที่แล้ว

    Awesome,thank you

  • @igoraleks9282
    @igoraleks9282 ปีที่แล้ว

    A very clear explanation of what symbols are but why do we need Symbols?

  • @Cognitoman
    @Cognitoman 5 ปีที่แล้ว

    Pretty cool mean, could you use these in react as a unique identifier for JSX elements ?

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  5 ปีที่แล้ว +1

      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.

  • @yinonelbaz5309
    @yinonelbaz5309 3 ปีที่แล้ว

    This tutorial covers what exactly Symbols are and how you can manage them.

  • @mattmidtvedt2555
    @mattmidtvedt2555 4 ปีที่แล้ว

    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!

  • @chiculitamihaela8076
    @chiculitamihaela8076 2 ปีที่แล้ว

    Thanks!

  • @Luxcium
    @Luxcium 5 ปีที่แล้ว

    Will you do (or have you done) a tutorial on Symbol.toPrimitive

  • @pinkleprechaun52
    @pinkleprechaun52 2 ปีที่แล้ว

    What is the purpose of the symbols not showing in the for loop?
    Btw, thank you for the great explanation.

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  2 ปีที่แล้ว +2

      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 - th-cam.com/video/OC9D9REnXPw/w-d-xo.html . It does not appear when you do a for loop.

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  2 ปีที่แล้ว

      And th-cam.com/video/NoUPIQobeLw/w-d-xo.html

    • @pinkleprechaun52
      @pinkleprechaun52 2 ปีที่แล้ว

      @@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 :)

  • @sourishdutta9600
    @sourishdutta9600 5 ปีที่แล้ว

    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.

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  5 ปีที่แล้ว +2

      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.

    • @sourishdutta9600
      @sourishdutta9600 5 ปีที่แล้ว

      @@SteveGriffith-Prof3ssorSt3v3 yes thank you.

  • @Retrofire-47
    @Retrofire-47 11 หลายเดือนก่อน

    Similar to the `Optional chaining '?.'` operator, accessor, thing, finding an actual _use_ for the Symbol data type eludes me completely

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  11 หลายเดือนก่อน +1

      nullish operators:
      th-cam.com/video/uJ9ylqqDuTI/w-d-xo.html
      th-cam.com/video/onVLVOP7-gI/w-d-xo.html
      Example using Symbol to build a custom iterator - th-cam.com/video/OC9D9REnXPw/w-d-xo.html

  • @CodeProps
    @CodeProps 5 ปีที่แล้ว +3

    I still don't understand what practical uses for this, need to re-watch I guess.

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  5 ปีที่แล้ว +1

      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.

  • @eswararaoravada2895
    @eswararaoravada2895 5 ปีที่แล้ว +1

    Any use-cases.where it is useful. except iterators & generators

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  5 ปีที่แล้ว +1

      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

  • @StevenVachon
    @StevenVachon 4 ปีที่แล้ว

    But why would we want unique identifiers for object properties?

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  4 ปีที่แล้ว +2

      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.

  • @saishdesai408
    @saishdesai408 4 ปีที่แล้ว

    what is $ sign in javascript??

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  4 ปีที่แล้ว

      $ is just one of the possible characters that you can use for a variable name in JavaScript.
      th-cam.com/video/ILx2rvQDLDk/w-d-xo.html

  • @johnconnor9787
    @johnconnor9787 2 ปีที่แล้ว

    Could you show a real life implementation of this

  • @froggyy
    @froggyy 3 ปีที่แล้ว

    What is the point of symbol

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  3 ปีที่แล้ว +1

      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.

  • @mervinmarias9283
    @mervinmarias9283 ปีที่แล้ว

    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.

  • @ajunwaowoicho1723
    @ajunwaowoicho1723 ปีที่แล้ว

    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.

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  ปีที่แล้ว +1

      My content has changed since I started making tutorials 5 years ago

    • @ajunwaowoicho1723
      @ajunwaowoicho1723 ปีที่แล้ว

      @@SteveGriffith-Prof3ssorSt3v3 ok, thanks proff. I am actually a beginner so I thought to let u know how we see things from where we're standing

  • @imtanuki4106
    @imtanuki4106 ปีที่แล้ว

    everything you'd ever want to know about symbols...except why and how to use them, in an app.

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  ปีที่แล้ว

      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.