 The rest of the podcast now, you're just going to do a high pitched for anything I say. It's a fucking silent life. Ne-ne-ne-ne-ne-ne-ne-ne-ne-ne. So, official starting word of any HTTP2 or 3 episode, I've been having a look through some of the TC39 proposals. Oh no. Oh yes. And these are the ones which are kind of like Stage 0, Stage 1, like the really early stuff. Okay. So I would like the Serma score for each of these things that I'm going to show you. Okay, are we talking? Minus 101. From interesting to interesting, that's what I want. So, the first one I'm going to show you is this. This is promise.try. Interesting. It's an initial verdict. Okay, here's the thing. I'm going to try to figure out what it is in YouTube if I'm right. All right. This is basically the reverse of a wait, where a wait turns a rejected promise into a throw and this one turns a throw into a rejected promise. It will do that, but also other things. Because if you do, okay, so let's take a look at this, which is that both of these things are doing almost exactly the same thing. Okay. So in here, this is an async function. So I can write code in there. If it throws, it's going to return to a rejected promise. If I return a thing, it's going to be packaged into a promise and that's what P is going to be. It will be that return value. The only difference between these two is this function here is queued on a microtask and this one is not. Interesting. Yep, basically this is the implementation of try because a promise callback will run straight away. What's different of just an async ify? Async ify is exactly the same. So I'm a verdict on promise.try? Nope. I have needed this in the past, but I agree that async ify is, although it kind of looks a little bit ugly in code sometimes. I agree it's taken a little bit. The only thing that's nice about this is that ifys are always confused because you see a function and it's only like, oh, I'm invoking it. So this one would make it like, oh, obviously I can see at the start you're invoking it. Yes, and you know what, it's a bit off topic, but that's why I don't like APIs that have a callback first, then some extra stuff afterwards. At EventListener, which has all of its set timeout as a perfect one because you're scrolling down the page, like down this massive function. It has a lot of lines of callback code. Yeah, and then just to find out. Exactly. Or you're looking at this, you know, EventListener going, this doesn't really make sense and you get to the bottom, it's like once, true, like, oh, okay, now let's read all of that again. Okay, but anyway, that's off topic. Next thing I want to talk about. Stage zero. That is probably stage zero or one. These are the things I didn't commit to memory before we sat down. Right, this. Oh, I know where this is going. I'm looking forward to that one. Oh, okay. I think so at least. But I'm going to, oh, Jake, where's this going? Top acting, sir. Well, what we're doing here is we're trying to get the value of data.photos.length, but photos might be not an object. Like it could be a null or an undefined or something like that. So, this syntax. Oh, we're called the coalescing null operator or something? Yes, yes. Or some reordering of those sounds into the correct thing. I think it is called that actually. So, yeah, what happens here is if it gets to photos and photos is null undefined, it just stops right there. Interesting. It exists. It's exciting. It's important to this so much because every now and then, especially when you like take user data, like user options object and you have to check if it's actually there. And if so, if you want to inspect it, just write it down with a question mark and it would look so much better. Exactly. There's another thing I want to point out here and that's that I recently got a kiss on in case anyone's wondering why my hands are shredded. That's why. Anyway, this works as well. Oh, yeah. At least it's the same. Yeah, whatever. So, just to be clear, like if the thing that you question mark is null, then the entire return value will be null. Yes, exactly. So, a value would be null in this example. This works as well, which I quite like. I mean, the dot is a little bit confusing. I would have expected question mark parentheses. Yeah. I imagine that might be a clash of syntax, maybe with the ternary operator or something like that. Oh, that's so annoying. Yeah. I can see that. So, now there's a one character look ahead. Well, you know, one non-white space character look ahead to decide what to do. So, yeah. But this is saying if whatever is present, call it, if not, it becomes null. So, yeah. Cool. What's the sum of score? Interesting. Interesting. I think so too, actually. I quite like that one. Right. Have you ever ended up with code like this before because you want to create a constant, but computing that constant requires a bit of work? And technically. So, you write a function. That's where you write a function. Thank you, exactly. So, an answer here is to make a self, an iffy, a self-executing function that returns the thing. Brilliant. Great. Job done. The proposal is a do block. Oh, the do, how very functional of us. Exactly. So, this is the idea is that you could put this where you would put statements. So, especially useful in things like JSX, which is all statements. You can't put ifs in there. But with a do, you would be able to put an if in. And the final statement in the do is the value that's returned effectively. So, what can you, you can put any form of JavaScript code in the do or just a subset because I would have expected explicit returns in the do block? No, it's just the last statement. I actually made a mistake when I first wrote this code. I missed the else off because I thought, oh, you know, I had the, because normally when I write code like this, I don't do, if I'm returning values, I don't do the else because all the other codes ended and I just had logged out and I was like, oh, I'm now breaking it. Oh, so basically you write just code and then the last, the return value of the last statement. And this is all one statement for the record, right? Yeah. This is one big ifs. Yeah, it's kind of essentially the last thing that's that's executed. It's kind of the thing that would appear in the console if you pasted this in. Interesting. So what? Interesting. Yes, it's nicer to read if you just say do. But then again, I think I would love do to just be a sugar over an ify. And you'd be like, just let me do returns. Like if you want to do an early return. I do not. I think you're right. I think something that would be really nice here is an ify syntax that was clear from the first few characters. You see the start. Oh, this function is going to be invoked immediately. I just just execute that block of code. It's allowed to return though. Would be nice. It's a problem worth looking at. Not sure I like the solution. All right. Well, that's that's almost declared. That he hates that idea and everyone involved. I'm going to send this video to g39 after. So this one, we've seen this before, right? You've done examples like this. So we're saying hello world or default, right? Okay, it seems like we get going because it has a lot of synergy with the question mark thing. Ah, it is, it is. So the problem here is if hello world is an empty string and you actually want it, you know, you're wanting to say if world exists or undefined or zero. So this is the proposal. So what this means is use default if world is null or undefined. But not an empty string. Oh, this is the thing where you run into the trap where you're doing the or to have a default value, but then you realize, oh wait, zero and empty string are actually considered falsely, even though in this case they are legit values for me. Yes, exactly. Interesting. Interesting. Interesting. That's about okay. Okay, let's let's keep going. What does this do? It replaces the first plus with an M with a space and I've run into this so many times and if you don't want to replace all of them, you always have to go with the right axis. Exactly like that. And it's horrible, right? Because then you're horrible. Especially if you're doing things with slashes in already, get all of the horrible escaping. It's nasty. The proposal is? Yes, replace all. Yes. Interesting. Good. Do it. Ship it. All right. Excellent. Brilliant. All right. Moving on. Oh, this is so ruby. It is so ruby. This is where this has come from. So what would you assume this is? So there's two versions I could see. Either some function, it takes a parameter and returns a function and that then gets invoked with this thing or the block at the end just turns into the second parameter of some function. Second one, correct. Yes. It is sugar for that. Oh, the reactive people are going to love it. Right. And there's some interesting kind of syntax as you get with this. It's a lot of it's. It's very, very unidiotmatic right now. I mean, if you're putting the function into the language, it's by definition not really unidiotmatic anymore. But right now it feels very foreign. It's, yeah, it does. It feels very foreign and it's a lot. It's a new syntax for something that, all right, how different really is that? What are we really gaining now? I think you would have to see it with like more chaining. Because for example, could I make some function then return a new function that takes a function and then just chain these blocks together? Oh, wow. Is it something that we want to allow? Oh, yeah. I didn't even consider that. I wonder if that would be valid syntax. Ooh, exciting. Worth looking into. I mean, I'm a big fan of functional programming in general. Watch my supercharged series coming up on functional JavaScript programming. Right. Okay, next one. It's the last one. Okay. Familiar with this syntax? It's an array. It's an array. Excellent. One point for some. Congratulations. You keep your job. Oh, last item. I remember being looped into a Twitter flame war around this. Oh, yeah. Because last item I'm on board with. Yeah. Because it's the only way to do it right now is array angle brackets and then in there array length minus one. Minus one. Which also I think is acts weird if the array is empty or does it just do undefined? Because then you would do array minus one. You'd be on the minus one thing. I don't even know right now. And then suddenly you have to think about these things. Holy arrays. So this would be well-defined. If it's empty, it's probably going to be undefined or something. It's going to define and it's a nice and easy to read way to get the last item. And I agree. I've wanted this all the time and it's nice that it's also a setter. Which is great. So this is me making an array one, two, four. That is nice. The thing that we had on Twitter was, well, then we should also have first item. Well, actually the way it came to it is I saw someone going, I just I'm really excited about first item. I didn't mention last item. I was like, really? We have zero. Zero. It's pretty concise. It's actually shorter. Okay. Like I understand the excitement for last item. And the proposal only mentions last item. It doesn't mention first item. So yeah. Okay. So I was those. What's your favorite? What do we have? I think it's coalescing null. I think it has the biggest impact for me. Probably because I've been writing a lot of like user-facing slash library code recently. So you always end up handling options, objects, and then this whole verification stuff just gets annoying. Yeah. And you can always pass something like this off to a function that gets the last item of an array. It's not amazingly pretty, but it does the job. Whereas the null thing is really difficult to sort of libraryify. Yeah. And then you have functions and you have to chain them. It gets weird. It gets weird. Okay. Yeah. That's all I had. We should talk about in like after the next GC39 meeting an update on did they move on or not. There's actually loads more proposals. So if I once again can't think of a code episode to do, we're going to go through some more. I like it. And we're going to go and I'm sure there'll be more proposals by then. So we'll keep doing this as a kind of regular thing. Until then. Until then. I accrued myself to a massage. A massage? A massage. Is it massage or massage? I don't know. I don't know. I'm still confused. Message. A message. A message. A message.