1
00:00:00,260 --> 00:00:05,870
The next type of operator is comparison operators.

2
00:00:06,290 --> 00:00:10,490
And this is used to compare values together.

3
00:00:11,040 --> 00:00:17,160
And always comparison operators retains true or false.

4
00:00:17,460 --> 00:00:21,720
So let's look at examples of these operators.

5
00:00:21,720 --> 00:00:32,130
But let me provide the comment here as that meaning it is used to compare values together and I'll provide

6
00:00:32,130 --> 00:00:34,020
or change the color.

7
00:00:34,260 --> 00:00:39,480
The first type of operator is called the equal to.

8
00:00:40,270 --> 00:00:46,570
And let me provide the definition so that we can follow along pretty easily.

9
00:00:46,870 --> 00:00:56,590
This is used to check if the values of two operands are equal or not, regardless of their type.

10
00:00:57,100 --> 00:00:59,110
Let me give you an example.

11
00:00:59,500 --> 00:01:07,570
Before that, let's provide or let me provide the railroad case study so that we can build on that to

12
00:01:07,570 --> 00:01:08,700
explain more.

13
00:01:08,710 --> 00:01:10,570
And this is the question.

14
00:01:10,750 --> 00:01:20,860
You have different measurements of height one from an input field and that is string and the other from

15
00:01:20,860 --> 00:01:22,570
a calculated result.

16
00:01:22,570 --> 00:01:24,310
And that is number.

17
00:01:24,520 --> 00:01:28,900
You need to know if they represent the same height.

18
00:01:29,110 --> 00:01:33,670
As you can see for this case study, it does not provide the value.

19
00:01:34,000 --> 00:01:42,830
And as a developer, you need to deduce and assume some values based on this, we are going to assume

20
00:01:42,830 --> 00:01:43,970
some values.

21
00:01:43,970 --> 00:01:49,790
But the key point here is we need to provide a string and then a number.

22
00:01:50,000 --> 00:01:54,110
So here I will say let's hide a.

23
00:01:55,450 --> 00:01:58,750
Equal to a string of 150.

24
00:01:58,780 --> 00:02:01,660
Now we are done with the first one.

25
00:02:02,310 --> 00:02:05,970
The second one is Let Hyde be.

26
00:02:06,960 --> 00:02:09,720
Is equal to 150.

27
00:02:10,550 --> 00:02:15,660
Now we are going to compare if these two values are the same.

28
00:02:15,680 --> 00:02:26,180
Therefore, I'm going to declare a variable called const and I will say result is equal to height.

29
00:02:26,210 --> 00:02:38,750
A is equal to double equal to two height B If we console log the result, what will be the answer is

30
00:02:38,750 --> 00:02:40,280
going to be true.

31
00:02:40,310 --> 00:02:47,990
Now let's go ahead and find out if I set for or console log the result.

32
00:02:48,110 --> 00:02:50,450
As you can see we have true.

33
00:02:50,840 --> 00:02:55,010
This is one of the cases why JavaScript is so weird.

34
00:02:55,310 --> 00:03:01,220
Over here we are comparing a string and a number and it gives us true.

35
00:03:01,990 --> 00:03:11,200
And if I change to a number with 2C2 if I bring back the result, we still see two.

36
00:03:11,320 --> 00:03:14,050
Now let me bring back to a string.

37
00:03:14,410 --> 00:03:21,610
And if I change this one to triple equal to let's have a look and let's check for the answer.

38
00:03:21,610 --> 00:03:23,410
And we have false.

39
00:03:23,650 --> 00:03:32,890
So let's have the clear differences between the double equal to and then the triple equal to for double

40
00:03:32,890 --> 00:03:40,900
equal to it only checks the value without taking the datatype into consideration.

41
00:03:41,200 --> 00:03:46,960
The data type for this one is a string, and this one is a number.

42
00:03:47,620 --> 00:03:49,970
But for double equal to it has no.

43
00:03:49,990 --> 00:03:52,420
Take this into consideration.

44
00:03:52,780 --> 00:03:57,970
But for triple equal to it takes the data type and the value.

45
00:03:58,000 --> 00:04:05,560
That is why if you use triple equal to we have false because these are of different data types.

46
00:04:05,830 --> 00:04:07,660
And the next data type.

47
00:04:07,660 --> 00:04:14,590
So let me change this one to double equal to or triple equal to.

48
00:04:15,370 --> 00:04:19,600
The next operator is called the not equal to.

49
00:04:20,050 --> 00:04:28,870
And as the name implies, it is used to check if the values of two operands are different regardless

50
00:04:28,870 --> 00:04:29,860
of their type.

51
00:04:30,070 --> 00:04:34,930
Let me provide the description so that you can follow along pretty easily.

52
00:04:34,960 --> 00:04:38,920
Likewise, the case study for this one.

53
00:04:39,100 --> 00:04:46,290
You want to know if the number of apples you have is different from the number of oranges.

54
00:04:46,300 --> 00:04:51,790
So this one too, we can deduce some logic here and it goes like this.

55
00:04:51,820 --> 00:04:58,330
We are going to declare a variable called apples and it's equal to five, we are assuming.

56
00:04:58,480 --> 00:05:01,000
And then let's oranges.

57
00:05:02,270 --> 00:05:04,640
Also equal to seven.

58
00:05:05,220 --> 00:05:06,330
For this one.

59
00:05:06,330 --> 00:05:10,500
We are going to check if the number are different.

60
00:05:10,590 --> 00:05:19,620
So let's go ahead and use the not equal to and I will declare a variable called result.

61
00:05:19,650 --> 00:05:22,110
Remember, we have declared it here.

62
00:05:22,110 --> 00:05:23,670
So let me change this one to result.

63
00:05:23,670 --> 00:05:28,410
And I can comment out because I want to use the same variable here.

64
00:05:28,560 --> 00:05:34,140
So here apples is not equal to oranges.

65
00:05:34,470 --> 00:05:37,080
And if you console.log result.

66
00:05:37,110 --> 00:05:38,610
Let's have a look.

67
00:05:38,610 --> 00:05:41,190
And indeed, it is true.

68
00:05:41,870 --> 00:05:45,860
The next example is called not equal to.

69
00:05:45,890 --> 00:05:50,390
But this one we are going to use double equal to.

70
00:05:51,130 --> 00:05:52,660
And it goes like this.

71
00:05:52,660 --> 00:06:01,090
I will provide the definition and it says that this type is used to check if the values and type of

72
00:06:01,090 --> 00:06:04,000
the two operands are not identical.

73
00:06:04,390 --> 00:06:10,330
As you saw in the previous example, by using double or triple equal to.

74
00:06:11,040 --> 00:06:13,950
And let me provide the case study.

75
00:06:14,800 --> 00:06:16,330
Which is this?

76
00:06:17,240 --> 00:06:18,320
For this one.

77
00:06:18,320 --> 00:06:26,300
Once again, you have to hide measurement, but you want to know if they are not the same value or type.

78
00:06:26,630 --> 00:06:32,210
And we are going to use the height example for this one.

79
00:06:32,450 --> 00:06:37,520
So we are going to use double equal to by using the not symbol.

80
00:06:37,700 --> 00:06:41,420
So here I will say let's result.

81
00:06:42,420 --> 00:06:48,090
Equal to height A is not equal to height B.

82
00:06:49,460 --> 00:06:51,950
So let me comment out this one.

83
00:06:53,170 --> 00:06:57,220
And here if I console log the result.

84
00:06:57,490 --> 00:06:58,660
Let's have a look.

85
00:06:58,780 --> 00:07:08,590
And it is true because these two are different because it is checking the type and then the value.

86
00:07:09,900 --> 00:07:13,740
The next example is the greater than symbol.

87
00:07:14,250 --> 00:07:17,220
And for this one it is more descriptive.

88
00:07:17,250 --> 00:07:21,180
We are checking if a number is more than the other.

89
00:07:21,570 --> 00:07:25,080
So here I'm going to provide some case study here.

90
00:07:25,350 --> 00:07:33,750
It says that you have two cars and you want to know if the first car is moving faster than the second

91
00:07:33,750 --> 00:07:34,260
car.

92
00:07:34,920 --> 00:07:38,720
So we can assume some values here.

93
00:07:38,730 --> 00:07:44,190
So we can say let speed equal to 60.

94
00:07:45,180 --> 00:07:51,090
And let speed be also equal to 50.

95
00:07:51,510 --> 00:07:56,250
Let's check if one car moves faster than the other.

96
00:07:56,490 --> 00:08:04,500
Therefore, I'm going to comment out or even remove this one so that I can reassign to a variable called

97
00:08:04,500 --> 00:08:05,310
result.

98
00:08:05,340 --> 00:08:06,720
So let's.

99
00:08:07,640 --> 00:08:11,690
Result equal to speed a.

100
00:08:13,400 --> 00:08:15,680
Is more than speed.

101
00:08:15,710 --> 00:08:16,010
Be.

102
00:08:17,290 --> 00:08:20,800
And the answer is going to be true.

103
00:08:21,100 --> 00:08:28,720
If I set for resort, we have true and then the opposite way is the less than.

104
00:08:28,870 --> 00:08:37,480
So here I'm going to change this one to use less than here and I'm going to copy and then just change

105
00:08:37,480 --> 00:08:40,780
the operator to less than.

106
00:08:40,809 --> 00:08:44,340
Now I can comment this one a speed a.

107
00:08:44,380 --> 00:08:45,880
Less than speed B.

108
00:08:45,910 --> 00:08:47,810
The answer is no.

109
00:08:47,830 --> 00:08:50,170
So here you're going to see false.

110
00:08:51,020 --> 00:08:56,120
Then the next operator is using greater than or equal to.

111
00:08:56,390 --> 00:08:59,060
And I'll provide the definition.

112
00:08:59,660 --> 00:09:08,810
And this is used to check if the value of the left operand is more than or equal to the value of the

113
00:09:08,810 --> 00:09:09,950
right operand.

114
00:09:10,280 --> 00:09:13,610
And let me provide some case study here.

115
00:09:14,120 --> 00:09:15,780
And it goes like this.

116
00:09:15,830 --> 00:09:26,420
You are comparing two weights of boxes and want to know if the first box weighs as much as or more than

117
00:09:26,420 --> 00:09:27,950
the second box.

118
00:09:28,100 --> 00:09:32,870
So let's declare the first box weights as weight A.

119
00:09:34,220 --> 00:09:38,660
And I'll assign 250 and let.

120
00:09:39,460 --> 00:09:40,510
Wait be.

121
00:09:41,830 --> 00:09:43,960
Equal to 50.

122
00:09:44,500 --> 00:09:53,200
So for this one, we are going to check if weight A is more than or equal to width B and is going to

123
00:09:53,200 --> 00:09:54,070
be true.

124
00:09:54,100 --> 00:10:06,220
So let's declare a variable called result and is equal to is with a more than or equal to weight b.

125
00:10:06,990 --> 00:10:14,700
And let me comment this one out or I can remove the result here because I want to use it down here.

126
00:10:15,090 --> 00:10:26,210
And if I console log the result and indeed it is true because with a is more than or equal to with B,

127
00:10:26,220 --> 00:10:36,150
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

128
00:10:36,150 --> 00:10:42,110
the opposite one is less than or equal to and it goes like this.

129
00:10:42,120 --> 00:10:50,910
So it is with a less than or equal to with B, the answer is false and indeed we have false.

130
00:10:51,660 --> 00:10:52,620
All right.

131
00:10:52,620 --> 00:10:56,940
So these are examples of the comparison operators.

132
00:10:56,940 --> 00:10:58,800
Let's continue in the next video.

