Let's get started with string comparison.
Well, so far we are down with that.
Strength matters because right now I have opened the gateway for you and you can learn any methods that
you want to use in your future project.
And always they are always online around and then find the particular strain metallurgy you want to
use in your future project.
Well, so let's comment out this one.
Let's start with a new concept which is called string comparison.
Meaning how can you compare string together in this video?
I'm going to expose to you sometimes how JavaScript behave the way we don't explain it, right?
But here the case you have no option unless you would be more about JavaScript before we can understand
sometimes the weird things about JavaScript.
So in this video, let's see how we can compare strings together.
That's what you call strain comparison.
So let me comment here.
And then, let's say string.
Comparison.
Yes.
Good.
So in order to compare whether one strain is more than the other, JavaScript employs what is known
as dictionary or lexical graphical order.
In other words, strings are compared by letter by letter.
Let's see ways of comparing strings.
For the meantime, let's compare letters together.
So let's consider that log this.
And now let's say that that's a less than B, if I save it, I got true because B comes after A.
So it means that B is more than A the first point.
The next point is, let me copy this one and then let's compare with the same letters, but different.
Sheep, for example.
One is uppercase and one is lowercase.
So let's comment on this one.
This one means that the the one that comes after the other is heavier.
So A is a list followed by B, C, D, and the rest with Z is the highest if you are comparing the both
lowercase together.
So when I say Z here or sorry lowercase z here, I go through because Z is more than a like the first
note.
But the second point is that we see that they are of the same type, but one is uppercase and one is
lowercase, so a is less than a uppercase.
A Well, this is false.
Always lowercase.
R Heavier than the uppercase.
Even there be more about this.
I will leave some documentation for it.
Read more about the order.
How they appear in a certain scale, but for the mean time give you some simple fact about this logic.
So the next point need to bear in mind is let's have one example here.
Let's say I have blue and then here is GLY.
Glee.
Before we safe and sound.
Can you tell me what the answer?
Okay.
Pause here.
Let me give you some facts before we come back to this.
Well, point number one is, bear in mind is that lower cases are more than upper cases.
Okay.
And we can determine where they are inside the internal encoding table of JavaScript.
And that's a unique code.
So if we want to learn more about this, we can go online and see which are where in the table or the
internal table of JavaScript.
That's this lettuce.
Okay.
For the meantime, let me give you the fact the simple way or summarize in a simple way would understand
here without reading those documentation.
So one point again is that lower cases are more than upper cases if they are of the same type.
Point about two is that if they are of the same type, always the lower case is more than the other
as like I said.
And then the order a is the least followed by B, C, D, and the order z is the highest.
So the next point is that if you are checking for letters like this one, like this one.
So the first it would check the first letters on both sides.
Checking.
Yes, it's checking the first letters on both sides.
If one is more than the other, it will return.
True.
But if they are equal you to move the next letter until it returns true or false.
And lowercase are always more than the uppercase letters of the same type, because the lowercase character
has a greater index in the internal encoding table of JavaScript.
That is a unicode.
So if both strains end at the same length, then they are equal.
Otherwise the longer string is more.
So let me let me let me show you that grammatically over here.
First, I'm going to check both sides.
Let's see if want to check.
We have G and we have G.
They are the same type, so they are equal.
So you move the next letter.
Small error and more error.
Yes, they are equal now.
Small and then small.
E which one is heavier?
Well.
E comes after all or comes after E in the case.
Or comes after e meaning that or is heavier than E therefore now this one is true.
True here, and this one is false.
So it means that glow is not less than glee because o is more than E, therefore the whole logic will
exit and when to return the answer.
So for this one, if I save it, for me it's going to return.
False moment of truth.
Yes, indeed.
We have false over here.
So that is it about that.
So if I change, let's say this one to also us.
Oh.
Now we have uppercase.
Then we have lowercase.
Which one is going to retain the same thing or is heavier than this one?
So same as what force?
If I save it, I still see force.
All right, so that's the basic explanation about how we can compare string together.
So we are done with that.
So let me bring it back to Glow and this one to us, Glow.
Okay.
The next comparison is comparison of different types.
Let's see how we can compare.
Compare string of different.
Types.
How is it possible?
Well, when comparing values of different types, JavaScript convert the values to numbers and even
more.
And the numbers better.
Understand this and remember that one to aim for this one we have talk about it about the equality,
the double, and then the triple equals sign, how it works.
So let's compare with different types.
So let's console.log.
Let's say a is more than I mean.
Okay, let me say.
Yeah, A is more than two.
Let's see.
No is force.
A is never more than two here.
So it's false here.
So true.
So if you're trying to compare this one, how is it possible?
Why do we got false?
Because two is more than a that's the first scenario here.
The second scenario here is if you are trying to compare a string and number, again, let's see with
this example.
So let's say that I have here as five and then here also as five.
How is it going to happen for this one if I save it?
It is false because five is more than what this file.
By default OC by default JavaScript behind this scene doing the convention for us.
Okay.
And would that be more about why this is okay?
So if I also bring let's say.
Though we quoted, what would be the answer going to be true if I say it?
I got true because for equal sign it compared the values without taking into consideration the data
type of the value.
Because the data type of five is a string and this five is a number.
So if we want to have strict comparison, we use triple equal two.
Now I got false because a string can never be more.
Cannot be equal to what five?
There's one word in JavaScript.
How can you compare a string to a string with a sign?
And you say it is true, but behind the scene is doing the implicit I mean convention for us.
Then what about comparing I mean Boolean values, comparing boolean values.
So let's say comment out, not remove it.
Comment out this and now let's compare Boolean values.
So console.log.
Is true.
Equal to.
One.
Let's see.
Yes, it is one.
Because remember, if I bring triple equal to.
I get force if I bring double equal to.
I go true because always true.
Always.
What's not a false value is a true value and true value values start from one one, two, three, four
and zero is what force value.
So if I provide f here, force here.
Frost here is going to be improve.
Our force is always assigned a zero, so force is equal to zero meaning force.
Okay, that's about a boolean comparison.
So what about the last one is comparing with null and undefined now and undefined, let's say compare
null and undefined.
Let's see.
Console.log.
Let's I want to compare that now.
Equal to undefined.
Let's see.
It is true because these ones have no values.
But to make sure that you have a straight comparison you triple equal to.
In that case, you're going to get false.
So guys, that is simple.
I mean, string comparison we can make.
Well, the next video, let's start with a new topic called numbers.