WeakMaps - HTTP203

แชร์
ฝัง
  • เผยแพร่เมื่อ 6 ก.ย. 2024

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

  • @jurgentreep
    @jurgentreep 6 ปีที่แล้ว +49

    Jake with the

    • @jakearchibald
      @jakearchibald 6 ปีที่แล้ว +11

      Jurgen Treep genuinely one of my favourite t-shirts. Big fan of the work those folks do.

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

      I should probably have said smile since I feel the same way.

  • @wmhilton-old
    @wmhilton-old 6 ปีที่แล้ว +15

    I thought WeakMaps worked exactly like Surma did! I'm so enlightened. I feel like I'm at the right level to really enjoy/benefit from these discussions. Thanks so much for this series.

  • @victornpb
    @victornpb 6 ปีที่แล้ว +3

    I had an algorithm that recursively traverse a cyclic object, so I had to keep track of visited objects, I used to push it to an array, then check visitedNodes.indexOf(obj) but I can just replace replaced it with a set. I had no reason to use the WeakSet per se because I'm not leaking memory, but @bmeurer at V8 said it is cheaper because It doesn't have to keep iteration order.
    Another use case is for implementing event buses, that doesn't leak memory when the handler goes out of scope.

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

      I think I wrote a very similar piece of code last week - cloning an object with circular references. I used a WeakMap to track cloned objects.

    • @victornpb
      @victornpb 6 ปีที่แล้ว +2

      Jake Archibald I also ended up using weakmap because I also hold some metadata of each node

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

    This was really helpful for me to figure out why one would need to use a WeakMap or WeakSet for anything.

  • @MinusTechTips
    @MinusTechTips 6 ปีที่แล้ว +2

    i love how they are freely referencing facebook and mozilla and their products. *ehm microsoft ehm*

  • @ChunkyChest
    @ChunkyChest 6 ปีที่แล้ว +4

    so, do you know...... no ... good, next topic

  • @code-wiki8588
    @code-wiki8588 5 ปีที่แล้ว +1

    Hey guys,
    Can u guide me to a webpage or a blog where i can learn more about how to efficiently use javascript for memory management in v8.

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

      google.com ? :)

  • @nigelmrodgers
    @nigelmrodgers 4 ปีที่แล้ว +2

    huh?

  • @joonae5113
    @joonae5113 6 ปีที่แล้ว +2

    WeakMap working the other way around would solve the other (999/1000) usecases

  • @omri9325
    @omri9325 6 ปีที่แล้ว +4

    You guys are talking a bit unclearly, could you add subtitles or something? I really had hard time hearing/understanding what you are saying.

    • @dassurma
      @dassurma 6 ปีที่แล้ว +4

      Sorry for our mumbling! Subtitles are being worked on as we speak, they usually show up within 1 or 2 days :)

    • @omri9325
      @omri9325 6 ปีที่แล้ว

      Much appreciated!

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

      Your understanding is clearly not the focus. They are just having fun without realizing it may not be what people come here for. Sometimes it looks even rather disgusting than fun.

  • @sfincione2000
    @sfincione2000 6 ปีที่แล้ว +15

    It's quite funny to watch you guys pretend to not know this stuff =)

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

      i don't understand what makes you think they don't know what they talking about? like you are in your moms basement they working for google... like stfu

    • @MinusTechTips
      @MinusTechTips 6 ปีที่แล้ว +8

      wtf CodingPhase, did you even read the comment? quickly jump into keyboard warrior mode much?

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

      @@CodingPhase When did a google's title become a guarantee of an expertise? I have same opinion on already more than one topic they discussed.

  • @Rebel101
    @Rebel101 6 ปีที่แล้ว

    Nonsense!