The next type of operator is comparison operators.
And this is used to compare values together.
And always comparison operators retains true or false.
So let's look at examples of these operators.
But let me provide the comment here as that meaning it is used to compare values together and I'll provide
or change the color.
The first type of operator is called the equal to.
And let me provide the definition so that we can follow along pretty easily.
This is used to check if the values of two operands are equal or not, regardless of their type.
Let me give you an example.
Before that, let's provide or let me provide the railroad case study so that we can build on that to
explain more.
And this is the question.
You have different measurements of height one from an input field and that is string and the other from
a calculated result.
And that is number.
You need to know if they represent the same height.
As you can see for this case study, it does not provide the value.
And as a developer, you need to deduce and assume some values based on this, we are going to assume
some values.
But the key point here is we need to provide a string and then a number.
So here I will say let's hide a.
Equal to a string of 150.
Now we are done with the first one.
The second one is Let Hyde be.
Is equal to 150.
Now we are going to compare if these two values are the same.
Therefore, I'm going to declare a variable called const and I will say result is equal to height.
A is equal to double equal to two height B If we console log the result, what will be the answer is
going to be true.
Now let's go ahead and find out if I set for or console log the result.
As you can see we have true.
This is one of the cases why JavaScript is so weird.
Over here we are comparing a string and a number and it gives us true.
And if I change to a number with 2C2 if I bring back the result, we still see two.
Now let me bring back to a string.
And if I change this one to triple equal to let's have a look and let's check for the answer.
And we have false.
So let's have the clear differences between the double equal to and then the triple equal to for double
equal to it only checks the value without taking the datatype into consideration.
The data type for this one is a string, and this one is a number.
But for double equal to it has no.
Take this into consideration.
But for triple equal to it takes the data type and the value.
That is why if you use triple equal to we have false because these are of different data types.
And the next data type.
So let me change this one to double equal to or triple equal to.
The next operator is called the not equal to.
And as the name implies, it is used to check if the values of two operands are different regardless
of their type.
Let me provide the description so that you can follow along pretty easily.
Likewise, the case study for this one.
You want to know if the number of apples you have is different from the number of oranges.
So this one too, we can deduce some logic here and it goes like this.
We are going to declare a variable called apples and it's equal to five, we are assuming.
And then let's oranges.
Also equal to seven.
For this one.
We are going to check if the number are different.
So let's go ahead and use the not equal to and I will declare a variable called result.
Remember, we have declared it here.
So let me change this one to result.
And I can comment out because I want to use the same variable here.
So here apples is not equal to oranges.
And if you console.log result.
Let's have a look.
And indeed, it is true.
The next example is called not equal to.
But this one we are going to use double equal to.
And it goes like this.
I will provide the definition and it says that this type is used to check if the values and type of
the two operands are not identical.
As you saw in the previous example, by using double or triple equal to.
And let me provide the case study.
Which is this?
For this one.
Once again, you have to hide measurement, but you want to know if they are not the same value or type.
And we are going to use the height example for this one.
So we are going to use double equal to by using the not symbol.
So here I will say let's result.
Equal to height A is not equal to height B.
So let me comment out this one.
And here if I console log the result.
Let's have a look.
And it is true because these two are different because it is checking the type and then the value.
The next example is the greater than symbol.
And for this one it is more descriptive.
We are checking if a number is more than the other.
So here I'm going to provide some case study here.
It says that you have two cars and you want to know if the first car is moving faster than the second
car.
So we can assume some values here.
So we can say let speed equal to 60.
And let speed be also equal to 50.
Let's check if one car moves faster than the other.
Therefore, I'm going to comment out or even remove this one so that I can reassign to a variable called
result.
So let's.
Result equal to speed a.
Is more than speed.
Be.
And the answer is going to be true.
If I set for resort, we have true and then the opposite way is the less than.
So here I'm going to change this one to use less than here and I'm going to copy and then just change
the operator to less than.
Now I can comment this one a speed a.
Less than speed B.
The answer is no.
So here you're going to see false.
Then the next operator is using greater than or equal to.
And I'll provide the definition.
And this is used to check if the value of the left operand is more than or equal to the value of the
right operand.
And let me provide some case study here.
And it goes like this.
You are comparing two weights of boxes and want to know if the first box weighs as much as or more than
the second box.
So let's declare the first box weights as weight A.
And I'll assign 250 and let.
Wait be.
Equal to 50.
So for this one, we are going to check if weight A is more than or equal to width B and is going to
be true.
So let's declare a variable called result and is equal to is with a more than or equal to weight b.
And let me comment this one out or I can remove the result here because I want to use it down here.
And if I console log the result and indeed it is true because with a is more than or equal to with B,
if I change this 1 to 60, I'm going to have true because it is more than or equal to with B and then
the opposite one is less than or equal to and it goes like this.
So it is with a less than or equal to with B, the answer is false and indeed we have false.
All right.
So these are examples of the comparison operators.
Let's continue in the next video.