Transcript
00:00 Alright. Let's go ahead and solve this one. Hope you had a good time with it. So because numbers are limited to around nine quadrillion, so maybe sometimes you'll run into a situation where you need to store something bigger than that. JavaScript has a solution to this and it's called bigint, where you can just store arbitrarily large numbers.
00:21 So, there is a a global object, or constructor called a number and it has a property called max safe integer. And in fact, here, let's just console log that right here. And there it is, nine quadrillion. So we can't go any higher than that unless we're using a large number. And so that is what, big int is all about.
00:42 This is how you type that. The really interesting piece here is the n at the end of that. You'll notice that this is just a couple numbers higher than what you can actually represent in a, a regular number in JavaScript. So, there's our large number and here we can make another large number there. And we can actually sum those two numbers together and we've got Marty the money bag being pretty helpful here.
01:08 And then, that that's pretty much it. You cannot, mix large numbers or big big ints and regular numbers. They just don't play together nicely. So you have to decide, am I dealing with, like, ridiculously large numbers or am I, just doing regular numbers? There is a way to convert from one to another but, yeah, you're really not gonna run into this a whole lot.
01:33 Okay. So let's now talk about symbols. The other thing that you're not gonna run into a whole lot but you will occasionally, this is what a symbol looks like. So you've got your user ID. It is of type symbol, and, that's how you make one.
01:47 It's just symbol. Interestingly, I'll just throw this in here. You actually have this same sort of idea behind strings and booleans and and numbers as well. So there's boolean. And here we got our user ID.
02:01 And so this is, has, user ID or, user ID exists. And that would be Boolean user ID. So this is going to be a Boolean. You also have number. So, you can convert something into a number.
02:18 So that would actually convert into a number, into the number 23, which is kinda neat. And then you also and of course, you can pass an actual number into that number function. So that's interesting. And then you can also do string and that will take whatever value you pass into that and give you back, the string. And here, it's gonna be of type string.
02:40 So just fun little fact there. We're gonna talk a little bit more about constructors and functions in the future. But, yeah. So here's our symbol. It accepts, a name or a description.
02:52 That is not actually necessary. You don't have to pass it and you can, make as many symbols as you want. And what makes symbols unique is that they are unique. You can make, a bunch of these symbols, as long as, of course, you have individual names for each one of them, so that those variables are not overridden, then each one of these will be unique even though they have the same description. So if you were to try try and do a comparison or something, then they're not gonna compare.
03:19 And that's what this next part was all about. So here we're gonna say user ID and another ID and we can do, are equal as user ID triple use another, ID. They have the same description, but are they the exact same? Are they triple equal to each other? And the answer, of course, I led with that is no.
03:40 They are not the same. Are the symbols equal? No. And that's what makes a symbol unique is that it is unique. And so it can be used as a special identifier to, point to this.
03:49 So then you can have some value over here. Have a symbol or, yeah. Have a symbol kinda be a reference to that and then pass a symbol around. And that's the only way to get reference to that. It's actually pretty interesting as a property of an object and we will look at those all later.
04:07 You will also run into a situation where you can create global symbols and then use symbol dot four, and that's how you can get the symbol, that is registered in this global registry to get the symbol with this description, which is kinda interesting. And there are a bunch of other methods on here. So there's dispose and async dispose and iterator, and all of this stuff goes quite a bit, more detailed and in-depth from what we're going to be doing today. So there you go. That is your, big int and your symbol.
04:43 Like I said, probably not gonna use that a ton, but it's interesting to know nonetheless. And when you run across, a number that has an n at the end, you'll know what to do with it. So hope you enjoyed that one.
