what is `Symbol` in js (intermediate) anthony explains

Поделиться
HTML-код
  • Опубликовано: 29 авг 2023
  • I recently was writing some JS and wondered what `Symbol` was -- and now that I know I'm sharing it with you
    playlist: • anthony explains
    ==========
    twitch: / anthonywritescode
    dicsord: / discord
    twitter: / codewithanthony
    github: github.com/asottile
    stream github: github.com/anthonywritescode
    I won't ask for subscriptions / likes / comments in videos but it really helps the channel. If you have any suggestions or things you'd like to see please comment below!
  • НаукаНаука

Комментарии • 11

  • @Phaust94
    @Phaust94 10 месяцев назад +8

    Some js - ahh, refreshing! Especially the === part.

  • @semasemasemasema
    @semasemasemasema 10 месяцев назад

    Can you make a video about pickle and serialization in python? Would love to see it

  • @alexismandelias
    @alexismandelias 10 месяцев назад +2

    So a global object for creating and storing unique objects which we want to distinguish from one another and which we want to be unique and immutable

  • @sparkyb6
    @sparkyb6 10 месяцев назад +5

    For those of us that are more familiar with Python (which based on the topics of your channel I assume is most of us), it sounds like they mostly service the same function as Python's dunder method? There are two big differences I see. It seems like JavaScript needed a separate sort of namespace instead of just using unlikely to be used names because JavaScript objects are used like objects and like dictionaries, so you wouldn't want your specially named member to be iterated like a normal key (I assume that iteration skips symbols). The other difference that is nice is that because symbols are singletons, users can create their own without conflicting with future built-in symbols even if they share the same "name", whereas if I declared my own dunder method in Python, I could be in trouble if someone else uses the same name in the future.

    • @anthonywritescode
      @anthonywritescode  10 месяцев назад +4

      indeed! python has this problem all the time because people "invent" their own double-double-underscore methods that later get clobbered by the stdlib inventing the same one -- Symbol doesn't have this limitation since they're entirely separate namespaces

  • @kai3341
    @kai3341 10 месяцев назад

    Thank you for video. Also thank you for your English

  • @YameenMohammad-fw1n
    @YameenMohammad-fw1n 10 месяцев назад +2

    Anthony, can you please make a video on how a programming language is made? actually I am trying to understand that how language is made but having some doubts. so please make a video. Thanks in advance

  • @qexat
    @qexat 10 месяцев назад

    `Symbol.bind`: Symbol is a monad?? 😮

  • @q.w.e.r.t.y
    @q.w.e.r.t.y 10 месяцев назад

    Basically a JS version of Python's __iter__ 🤔

  • @33v4.
    @33v4. 10 месяцев назад

    niiiice