1 00:00:00,660 --> 00:00:02,160 Hello and welcome. 2 00:00:02,250 --> 00:00:13,050 In this video are be introducing you to the javascript comparison operators javascript comparison operators 3 00:00:13,140 --> 00:00:23,670 are used to compare values and will return a boolean result boolean basically remains true or false. 4 00:00:23,670 --> 00:00:33,180 So when you use javascript comparison operators it will always return either a true value or a false 5 00:00:33,390 --> 00:00:33,780 value. 6 00:00:34,800 --> 00:00:41,640 So this is basic table illustrating some comparison operators. 7 00:00:41,640 --> 00:00:50,810 So I'll start from the top which the first is known as the equal operator and is represented with the 8 00:00:50,820 --> 00:00:52,980 double equal symbol. 9 00:00:53,460 --> 00:00:54,960 So what that does. 10 00:00:54,960 --> 00:00:58,560 It checks if values are equal. 11 00:00:59,230 --> 00:01:08,160 OK so if you want to compare two values a core you use the equal to operator if you want to check if 12 00:01:08,160 --> 00:01:12,410 values are equal both in value and data type. 13 00:01:12,480 --> 00:01:20,310 You use this strictly equals 2 which is represented with a triple equal sign is single. 14 00:01:20,310 --> 00:01:29,610 Equal is used to assign a value so we must be careful between the distinction between single equals 15 00:01:29,730 --> 00:01:30,850 or double. 16 00:01:30,950 --> 00:01:36,800 If you want to check if something is equal to something you use a double equal so if you want to assign 17 00:01:36,810 --> 00:01:41,920 if I do like you do in variables you use just a single equal to one. 18 00:01:41,940 --> 00:01:48,780 Compare that the values are strictly equal in both data type and value. 19 00:01:48,780 --> 00:01:55,560 You use the triple equal symbol if you want to check if values are not equal. 20 00:01:55,680 --> 00:02:02,530 You use the exclamation mark that equals to sign that check. 21 00:02:02,670 --> 00:02:05,270 If the values are not equal. 22 00:02:05,760 --> 00:02:13,110 If you want to check if the values are strict you're not equal in value and data type. 23 00:02:13,110 --> 00:02:17,480 You use the exclamation and double a core symbol. 24 00:02:18,090 --> 00:02:25,140 So if you want to check if a value is greater than another value you use the greater than sign. 25 00:02:25,170 --> 00:02:29,390 For example you want to check if five is greater than two. 26 00:02:29,670 --> 00:02:35,340 If he wants to check if it values let's use the less than symbol with checks. 27 00:02:35,340 --> 00:02:43,800 If a number is less and another number of value you can also use the greater than or equal to which 28 00:02:43,800 --> 00:02:46,310 is represented by the greater than sign. 29 00:02:46,350 --> 00:02:48,370 And that equals to sign. 30 00:02:48,800 --> 00:02:49,880 What that does. 31 00:02:49,890 --> 00:03:00,150 It checks if the values is greater than or equal to the less than or equal to is represented by the 32 00:03:00,150 --> 00:03:04,870 less than symbol and the equals to sign these checks. 33 00:03:04,890 --> 00:03:13,380 If the value is less than or equal to so I'm going to jump into the console now and give you some basic 34 00:03:13,380 --> 00:03:17,690 examples of these comparison operators. 35 00:03:17,730 --> 00:03:24,740 So when you're using comparison operators they will always return either a true or false result. 36 00:03:24,780 --> 00:03:34,650 So for example if I want to check if four is equals to five that will return false. 37 00:03:34,650 --> 00:03:36,500 It calls for is not equal to five. 38 00:03:37,530 --> 00:03:47,120 If I want to check if a value is strictly equals in type and also in value. 39 00:03:47,730 --> 00:03:52,480 So what I do first I create a variable called a variable called X. 40 00:03:52,680 --> 00:04:05,120 I've gave this a value of 7 create a variable called Y and I'll give this a value of 7. 41 00:04:05,130 --> 00:04:14,320 But the 7 will be a string value so which means the data type is different from variable x. 42 00:04:14,370 --> 00:04:16,980 So now I can do a comparison. 43 00:04:17,040 --> 00:04:21,960 I can say X is equals to Y. 44 00:04:21,960 --> 00:04:27,490 This will return to true because both of them have a value of 7. 45 00:04:27,510 --> 00:04:34,080 Now if I use the triple A of course 2 it will return to force because the data type is different but 46 00:04:34,080 --> 00:04:35,220 the value is the same. 47 00:04:35,220 --> 00:04:45,450 So if I do X Triple A of course to y that will give me a result of force because they are not equal 48 00:04:45,450 --> 00:04:50,910 in data type the terrible way has a data type of string. 49 00:04:50,910 --> 00:04:57,970 You can tell because of the quotes that is and close around the value and variable x is numerical. 50 00:04:58,020 --> 00:05:05,200 Which has a value of 7 so they are the same in value but not the same in data type. 51 00:05:05,270 --> 00:05:07,580 So if you want to check two values are the same. 52 00:05:07,580 --> 00:05:23,540 For example if I say 8 is not equal to 7 that will return true because 8 is bigger than 7 so it is not 53 00:05:23,660 --> 00:05:24,750 equal to 7. 54 00:05:25,050 --> 00:05:33,380 So if on a check if in number is greater than another number on the check if 9 is greater than say 8 55 00:05:34,190 --> 00:05:38,460 that will evaluate to be true because 9 is greater than 8. 56 00:05:38,570 --> 00:05:53,620 If we say 8 we call 8 is less than say seven that again we evaluate to be true because aid is greater 57 00:05:53,920 --> 00:05:55,660 than 7. 58 00:05:55,840 --> 00:06:03,640 So here am using the less than sign comparing if aid is less than 7 that has returned force because 59 00:06:03,790 --> 00:06:07,090 aid is greater than 7. 60 00:06:07,150 --> 00:06:18,430 If I was to say 7 is less than 8 that will evaluate to be true because 7 is less than 8. 61 00:06:18,730 --> 00:06:23,720 So let me create a couple of variables a great variable a. 62 00:06:24,300 --> 00:06:30,540 I give you the value of 17 and I use the comparison. 63 00:06:30,580 --> 00:06:46,830 So if I see a is greater than or equal to 17 that will evaluate to be true because a variable a 17. 64 00:06:46,840 --> 00:06:51,790 So I'm saying a is greater than not equal to 17 so that evaluates to be true. 65 00:06:52,290 --> 00:07:00,780 If I create another variable say I quit a variable B and assign it a value of 10. 66 00:07:01,020 --> 00:07:12,610 And I want to check comparison so if I say is variable B less than or a course to 9 that will evaluate 67 00:07:12,610 --> 00:07:16,510 to be false because B is 10. 68 00:07:17,230 --> 00:07:23,140 So these are basic examples of comparison operators. 69 00:07:23,140 --> 00:07:31,590 Once you understand the basic concepts then it'll be easy for you to use the comparison operators are 70 00:07:31,620 --> 00:07:32,920 set for this video. 71 00:07:32,950 --> 00:07:34,120 Thank you for watching. 72 00:07:34,330 --> 00:07:35,020 Bye for now.