Transcript
00:00 So let's jump into it. We're gonna say our error pages is that and we'll export. What is this? Go away. Go away.
00:07 There we go. Okay. Great. So we've got our, object that has all of these keys. We can reference variables and use brackets to have those, whatever that value is be inserted into here.
00:21 Now, the thing is we could do a single quote right here to handle this and the whole reason we have to do that in the first place is because that syntax is just wrong. But you can quote the keys and it works just fine. The other reason why the bracket syntax is really nice is you can do any expression in here whatsoever. So we're doing variables, but you could do like, a template literal. That's like a, 400 yeah.
00:48 Sure. 400 status. Let's do four zero one. There we go. And that would be forbidden.
00:55 Right? I think. Or unauthorized. I can't I I don't remember. It's the 403 is the unauthorized, I think, or something like that.
01:02 Anyway, you got the right idea. So, you can do any expression in here. You could call a function in here as well and whatever that expression evaluates to, as long as it's a something that's too stringable, it can be set as a property in here. The other fun, like, little preview of the future is that you can also do symbol, symbol dot four, you know, unauthorized or whatever. You can, put symbols as property names as well and you'll, do that when we get into more advanced sort of things.
01:36 But, yeah, brackets, useful things. And, same sort of thing if we want error pages. Four zero four status. You can't do a dot syntax for that, of course. And so we're gonna do brackets and quotes for that one.
01:52 You and again, you can do a not found not found key right there. Pass a variable there. So it's the exact same thing whether you're creating the object or accessing a property. You just put the property name inside of brackets and now you can do any expression to determine what that property name should be. So, there you go.
02:09 That is, dynamic object keys. Good job.
