Welcome back, this is lesson five on Simbel data types, these are relatively new, primitive data
type that was added in twenty fifteen to JavaScript.
Invoking the function symbol and this is a specific class, produces an anonymous, unique value.
So this is a very, very interesting data type.
Basically, you're going to use this to create a specific I.D. that you can use for any type of unique
value purpose.
OK, so let's take a look at this type of code here and see what it does.
We're going to create a simple one and simple to notice that they're tied to the same type of information,
the same description right here inside the quotes.
And otherwise, these look exactly the same.
But they're not going to be the same value because what symbol does is create a unique value for each
time.
So we'll show you what that looks like.
OK, so we'll just let symbol one equal symbol and we're going to give this a description, OK?
And the description is totally optional.
It's not necessary at all.
We're going to use these descriptions just for the purpose of showing you what's going on here.
So we wanted to see whether or not these are the same.
So we'll do a console log and we'll say SIM one is exactly the same as seem to OK.
Now let's just see what happens.
It's going to return false.
Interesting.
OK, and obviously what that means is if we check for the opposite, it's going to return.
True.
OK, are they even partially the same?
No.
OK, now let's see if we can actually see what this value shows.
OK, when you consider this, it's not going to give you necessarily what you expect.
It's going to give you this special symbol.
Value and obviously, if we do the same thing here, it's going to look the same, but these are actually
separate values.
Remember, we checked to see if they were the same and they're not.
So if we want to actually get them as the same value, then we'd have to convert them to string's.
So if we convert both of them to string's.
We can do like this and then check it, those are true because those both would show up as just symbols,
simple like that.
But what's nice about these is they create these unique values.
Just like that, and if you wanted to access just the description you could by doing this so you can
control just the description.
And you get just the value that's there in the description.
So, as you can see, I could change it.
And it would change accordingly.
OK, so let's change that back.
Let's just for ease of understanding this, let's keep it that way.
And then run that again, you can see symbolism.
OK, so symbols are not used a lot, but you can use them as IDs in databases, as properties of objects,
and we'll get into objects.
OK, and that's it for DE.