 So do you know? No. Good. Next topic? So you know how JavaScript has all these primitives, like map, set, and weak map, and all these little nice data structures to build things? Yes. I wanted to build something with a weak map. Yes, and weak maps are great. They're underused, but great. We should say weak maps are a way of associating an object with another object. And see, you already said that, and this is where I was already wrong, because I just wanted to have strings mapping to objects. My concept was, I just have a list of keys, strings, you know, strings, strings, and I want to map them to objects, but I wanted to allow these objects to get garbage collected if necessary, which is the purpose of a weak map. You can have them in this map, but it doesn't prevent garbage collection. So we have this, so I should say that one of the good use cases for this is we used to put, if you wanted some data associated with a DOM node, say, we used to use Expandos. We used to just put DOMnode.underscore some data. We've got data attributes in the end, but what if you wanted to be objects or something? And a weak map's a great way of saying, this object that I don't really want to edit because I don't own its prototype I want to associate with this set of data I do own. So then if that DOMnode goes out of reference because it's like removed and nothing's got access to it, then your object as well can be garbage collected if there's no reference to it. So this is where I was wrong. It's not about the values not being garbage collected, but the keys not being garbage collected. Yes, so you get to keep your ability to access the value as long as you have the key. And that's why strings don't work. Yes. Because it's true for numbers as well. It's true for all primitives because they always exist. I found out that you need to have an object. I didn't understand why, but I guess this is where my mental model of the weak map was wrong because I thought the keys are just keys, but the values could get garbage collected even if they're still in the map. But it's the keys that still can get garbage collected if they're in use in the weak map. And you use your key to unlock the door to get access to the value you see. So that's it. You gave me the money. That's amazing. But yeah, yeah, we've got, and one of the things I've always been baffled by is like weak set. Yeah. So one thing that neither weak map nor weak set have. So I guess it's just like the weak map is this thing, you know, the keys can get garbage collected. Great. Excellent. Yes, that's true. That's true. And the set is just a set. The nothing can be in the tries, but also it doesn't prevent garbage collection. Yeah. It's a map with only keys. But neither of them are iterable. Right. Because that would expose garbage collection. Yeah. And that's a rule of the web for reasons I don't fully understand. But it is a rule that we don't want to expose that for some reason. Do you have a use case for weak set? No. So I think I figured it out. Have you ever used a weak map where the key is an object? I've never used a weak map, really. So I know. Have you not? Well, they were great. But where the value is true. So I. Which is a common practice to emulate a set? Exactly. And I had this. And this is because I've been thinking for ages. Like, oh, weak set is useless. And I had a piece of code where I needed to tag a request object in that. Like, I've dealt with this request object, or I've dealt with this response. Or I wanted to say, I wanted to say I've had. This is from the response. I wanted to say this is from the cache. And I started with just using an expando underscore from cache equals true. And then TypeScript complained. And so I thought, oh, I'm going to do this properly. OK. So I ended up with a weak map where the value was true. And I stood back and forth, now this is not a weak map. This is a weak set. I might actually have to use this. Because my current approach to what you just said, basically marking elements as having been processed already, is the expando thing. But instead of using underscore something, I use symbols. Because those are guaranteed not to clash. So it feels safe. Oh, yeah, yeah, yeah. But this one is arguably better. Right, because you're keeping the separation of data. And at some point, like the symbol thing, or it's possible that TypeScript will start complaining about that as well. Yeah, and I just augment the type in TypeScript. And so like this thing is now on this type. Right, OK. Which is what I did as well. And I wanted to not do that. And yeah, so that's the thing. If you want to associate a piece of data, there you go. I will try to refactor that. I learned something today that's become a better web developer. Although, to be honest, that is probably something that I would expect to be in React somewhere, or like any framework. Because I feel every framework, it has some kind of upgrading mechanism. Like you have DOM, and you need to, what did we call? Hydrate it. Yes. Or do any kind of processing on DOM. And so we are now aware that this is not only DOM, but this is tied to a React component, for example. Yep. This is where this would come into play. So this is something that HyperHTML uses. So we were talking about this in the last episode. If you've got a sort of, HyperHTML calls it a wire, but it's kind of like a partial. So you've got a list element, and you've got something to create list items from an object. HyperHTML wants you to use an object, give it an object that it will associate that set of data with. And so usually, that will be an object you have that represents the array of things. So that means that if stuff, when you go in, it's how it knows you're modifying an existing list. Rather than, yeah, use a weak map. And it means it doesn't leak memory, because as soon as your object goes out of reference, so does HyperHTML's cache. So I think it's really like they're a little bit of the unsung heroes of the JavaScript, the ECMAScript. What is it? It's ECMAScript, but sometimes it's JavaScript. Do you get dragged in by people's accents as well? Google being in San Francisco, whenever we go out there, I find one weekend, I'm like, yeah, yeah, is that like? I'm like totally into this. Totally there, yeah. I don't know what accent I was trying to do there. You have enough people that can tell the accents apart, because I guess it was totally American.