1 00:00:00,760 --> 00:00:01,880 Welcome back, ladies and gentlemen. 2 00:00:01,900 --> 00:00:04,850 Today, we're going to talk about JavaScript comparison operators. 3 00:00:05,050 --> 00:00:11,050 We already started doing this at the end of the last lecture, but we're going to continue today. 4 00:00:11,110 --> 00:00:12,970 Now, first things first. 5 00:00:13,000 --> 00:00:14,970 Did you finish your exercises? 6 00:00:14,980 --> 00:00:16,530 So lecture one exercise. 7 00:00:16,990 --> 00:00:24,490 So if you haven't, just find that file in the final folder in do doodle, do those exercise is going 8 00:00:24,490 --> 00:00:25,000 to help you. 9 00:00:25,180 --> 00:00:31,540 And if you don't know how to do them, then just open these solution solutions, file for the same lecture 10 00:00:31,540 --> 00:00:33,350 and yeah, you will have the solutions. 11 00:00:33,900 --> 00:00:41,050 OK, now before I start, we the operators and by the way, these are the ones that we are going to 12 00:00:41,050 --> 00:00:41,710 cover today. 13 00:00:42,200 --> 00:00:44,200 We did some of them, these four. 14 00:00:44,200 --> 00:00:49,810 But yeah, we're going to talk about a little bit more in these we will do in future because I kind 15 00:00:49,810 --> 00:00:52,060 of show you we haven't done very well yet. 16 00:00:52,540 --> 00:01:01,510 So let's open here now before doing the comparison operators, remember, I've just said that we have 17 00:01:01,750 --> 00:01:08,950 external file and we linking that file into the index, that HTML we'd calling this creep attack. 18 00:01:09,790 --> 00:01:12,580 Now we need to specify the type and the source. 19 00:01:12,850 --> 00:01:14,830 These SIRC stands for source. 20 00:01:15,700 --> 00:01:21,430 We just defined the source and that is in the same directory as the index HTML file. 21 00:01:21,830 --> 00:01:27,090 OK, that's pretty much clear, but this is called external Cyesis file. 22 00:01:27,370 --> 00:01:30,310 So the other way is we can run. 23 00:01:31,280 --> 00:01:38,830 A JavaScript code here in the console, right in the browser now the third way, it's very simple, 24 00:01:38,840 --> 00:01:40,800 we can actually run JavaScript here. 25 00:01:40,820 --> 00:01:48,440 So what I all need to do is open the script and close that script and put type here even without typing 26 00:01:48,440 --> 00:01:48,890 will work. 27 00:01:51,370 --> 00:01:53,860 Text SportWagen JavaScript. 28 00:01:55,000 --> 00:02:02,950 Now, here we are going to run, I mean, not run, we are going to type our JavaScript code, for example, 29 00:02:03,520 --> 00:02:06,420 was the most simple one. 30 00:02:06,760 --> 00:02:09,900 So hello from here. 31 00:02:09,940 --> 00:02:10,810 Now save it. 32 00:02:12,190 --> 00:02:13,210 Let's open up. 33 00:02:14,260 --> 00:02:16,520 And why you don't see the output? 34 00:02:16,540 --> 00:02:17,530 Well, because it's here. 35 00:02:17,560 --> 00:02:23,770 It's in first line and why it's in the first line, because these JavaScript will run before the external 36 00:02:23,770 --> 00:02:24,220 file. 37 00:02:24,910 --> 00:02:26,800 Right, if we put it back. 38 00:02:28,830 --> 00:02:37,410 This, then it will be on the last line, nice, so I'm not going to use in line and I'm not going to 39 00:02:37,410 --> 00:02:41,160 use the browser much, but definitely I will use the external files. 40 00:02:41,460 --> 00:02:47,100 And today we're going to create a new file called Lecture two that J is. 41 00:02:47,550 --> 00:02:55,620 Now, what I haven't told you is that J is now these dodgiest genius stands for JavaScript and it's 42 00:02:55,620 --> 00:02:56,910 called extension. 43 00:02:56,910 --> 00:02:58,650 And this extension will tell. 44 00:02:58,890 --> 00:03:06,270 Yeah, we are going to write a JavaScript code like this HTML saying, OK, this will be contained on 45 00:03:06,270 --> 00:03:07,230 HTML markup. 46 00:03:07,980 --> 00:03:08,550 Nice. 47 00:03:08,820 --> 00:03:10,140 So we create a cover. 48 00:03:10,140 --> 00:03:13,000 A lot of things that we haven't done in the previous lecture. 49 00:03:13,020 --> 00:03:20,340 Now if you don't see these icons that I have here, you can do you can search this code. 50 00:03:20,740 --> 00:03:23,810 There are different packages, icons like that. 51 00:03:23,850 --> 00:03:26,400 And this is the one that I have. 52 00:03:26,880 --> 00:03:28,140 So you can install it. 53 00:03:28,620 --> 00:03:29,580 I already have it. 54 00:03:29,970 --> 00:03:35,280 And yeah, it will change your icons like mine, but you can find different icons like this. 55 00:03:36,650 --> 00:03:41,000 Look, this is even nicer, you know what, I'm going to install it. 56 00:03:42,160 --> 00:03:47,540 Pendle see here is now set fire like a. good. 57 00:03:49,740 --> 00:03:53,830 And didn't change anything, probably needs to restart, it doesn't matter. 58 00:03:53,850 --> 00:03:55,560 OK, now you know how to install. 59 00:03:57,510 --> 00:03:58,610 I come back, right. 60 00:03:58,650 --> 00:04:03,590 But you're also going to work because if you haven't done before, yeah, it will pretty much work. 61 00:04:03,650 --> 00:04:11,360 OK, so we create the second lecture to not just file, but now here we need to common this one. 62 00:04:11,380 --> 00:04:22,380 So so select the entire line, command forward slash iMac or control forward slash in Windows and save 63 00:04:22,380 --> 00:04:22,550 it. 64 00:04:22,980 --> 00:04:29,730 But now I don't have links to any of the files, but I do want to link the my second file. 65 00:04:30,120 --> 00:04:33,900 Right, because now if I go here it will be empty. 66 00:04:33,910 --> 00:04:35,340 We don't have anybody here. 67 00:04:36,120 --> 00:04:38,280 And let's write console that log. 68 00:04:40,150 --> 00:04:43,810 In, say, Java script comparison. 69 00:04:46,010 --> 00:04:47,810 All parade tourists. 70 00:04:49,110 --> 00:04:51,820 If I misspelled something, don't please don't judge me. 71 00:04:52,140 --> 00:04:56,880 Now, if you click here, it will just make the full window right now. 72 00:04:57,120 --> 00:05:04,230 This No one means that I haven't save it, cuz now you know all those things about the Eskild, some 73 00:05:04,230 --> 00:05:05,540 teaching and things that I shouldn't. 74 00:05:05,700 --> 00:05:06,300 I'm sorry. 75 00:05:06,630 --> 00:05:10,440 And now let's start with the comparison operator. 76 00:05:10,460 --> 00:05:11,370 So first things first. 77 00:05:11,550 --> 00:05:16,710 I'm just going to write console that log five is greater than five. 78 00:05:17,460 --> 00:05:19,770 OK, Rod, console the log another one. 79 00:05:20,730 --> 00:05:23,300 And let's put a breathing space here. 80 00:05:23,970 --> 00:05:25,610 Let's copy this one here. 81 00:05:26,490 --> 00:05:29,940 Let's create a one comment. 82 00:05:30,300 --> 00:05:35,690 So the comments are two double forward slash, but we can make a multiple line comments and that's forward 83 00:05:35,710 --> 00:05:36,290 slash. 84 00:05:37,740 --> 00:05:44,700 Star, and we need to close this one star forward slash, so anything between these two, it's going 85 00:05:44,700 --> 00:05:49,820 to be considered as a common multi line comment. 86 00:05:50,340 --> 00:05:52,480 Now you know how to do a multiline comments as well. 87 00:05:52,680 --> 00:05:53,300 Nice. 88 00:05:53,850 --> 00:05:56,180 So save this one. 89 00:05:57,270 --> 00:06:01,080 Go back to five smaller than six. 90 00:06:01,710 --> 00:06:02,320 Nice. 91 00:06:02,370 --> 00:06:08,110 So what we do have I'm going to read it more scenarios and we're going to discuss about this. 92 00:06:08,110 --> 00:06:09,440 So greater or equal to. 93 00:06:09,750 --> 00:06:10,980 And you know what? 94 00:06:11,040 --> 00:06:15,540 Just to make sure that you have a breathing space between to be just more readable. 95 00:06:17,460 --> 00:06:17,840 Right. 96 00:06:18,380 --> 00:06:27,420 OK, it's not going to throw you in there, don't worry about it, so this will be greater than than 97 00:06:27,420 --> 00:06:32,490 we need to do five less than let's make it five less than fire. 98 00:06:34,170 --> 00:06:35,150 And that's it. 99 00:06:35,160 --> 00:06:35,970 Let's stop here. 100 00:06:36,010 --> 00:06:36,930 OK, save it. 101 00:06:38,040 --> 00:06:39,450 Now we have false. 102 00:06:39,450 --> 00:06:40,770 True, true, true. 103 00:06:40,800 --> 00:06:47,010 Oh, well, five is not greater than five and it's always going to return a boolean value called false. 104 00:06:47,160 --> 00:06:51,450 Right now the second one six is a greater than five. 105 00:06:51,630 --> 00:06:52,710 Yes, that's true. 106 00:06:53,790 --> 00:07:01,200 And the third one, what we are doing, we are seeing if is five greater or equal to five. 107 00:07:01,410 --> 00:07:07,220 So because it's not greater but is equal to and that's why it give us true. 108 00:07:07,590 --> 00:07:10,590 Now the other one is five is smaller, equal to five. 109 00:07:10,980 --> 00:07:13,320 And it's not smaller, but it's equal to. 110 00:07:13,560 --> 00:07:15,770 And that's why again, it's giving us true. 111 00:07:16,470 --> 00:07:19,890 Now what is about this operator? 112 00:07:19,890 --> 00:07:21,350 Have you seen something like this? 113 00:07:22,770 --> 00:07:29,490 Well, if it's your first time JavaScript that you haven't, probably five is equal, equal to five. 114 00:07:29,850 --> 00:07:32,040 Now, this is something interesting. 115 00:07:32,250 --> 00:07:35,460 So what this will do, it will throw true here. 116 00:07:35,860 --> 00:07:36,240 Right. 117 00:07:37,080 --> 00:07:38,250 Let's make something here. 118 00:07:41,820 --> 00:07:47,240 Let's make here for just to make sure that we have false yeah, do you know where we are? 119 00:07:47,340 --> 00:07:49,400 So we have false then that this one is true. 120 00:07:49,680 --> 00:07:55,190 So this equal equal to means equal value in equal type. 121 00:07:55,590 --> 00:07:59,370 So checking the value five is the same as this. 122 00:07:59,520 --> 00:08:04,170 And he's also checking the type and the type is a number and also both are true. 123 00:08:04,920 --> 00:08:06,510 So that is equal. 124 00:08:06,510 --> 00:08:10,080 But what about cancel that log. 125 00:08:11,330 --> 00:08:13,130 Five, equal to five. 126 00:08:14,540 --> 00:08:20,140 Do you think what will happen here now, we're not going to talk about this, it's called Inverleith 127 00:08:20,150 --> 00:08:22,290 left hand side assignment. 128 00:08:22,640 --> 00:08:29,720 Now we haven't done variables, but equals in JavaScript means assign. 129 00:08:29,720 --> 00:08:38,630 For example, if I have here variable call X, then I will say, OK, to this variable X give assign 130 00:08:38,630 --> 00:08:39,800 a value of five. 131 00:08:40,280 --> 00:08:40,640 Right. 132 00:08:40,940 --> 00:08:42,400 That's why I'm not going to cover. 133 00:08:42,650 --> 00:08:45,320 And I told you that we are going to do them in future. 134 00:08:45,380 --> 00:08:46,330 Actually I don't have. 135 00:08:46,610 --> 00:08:49,580 Yeah, probably I'm going to do the future so. 136 00:08:49,580 --> 00:08:50,000 Yep. 137 00:08:50,390 --> 00:08:51,050 That will be. 138 00:08:52,140 --> 00:08:53,950 So it's not working like that. 139 00:08:55,080 --> 00:09:01,530 That's why I don't talk now, the next one very interesting is that log six. 140 00:09:03,050 --> 00:09:11,480 Is not equal to five, make sure you understand what I'm trying to do here, not equal do five anything 141 00:09:11,600 --> 00:09:18,940 in JavaScript, you see exclamation mark, it will make that one to to be opposite of that one. 142 00:09:18,950 --> 00:09:19,190 Right. 143 00:09:19,310 --> 00:09:23,990 So this one means equal, but this means not in JavaScript. 144 00:09:23,990 --> 00:09:25,790 So it will make it the opposite. 145 00:09:25,820 --> 00:09:28,730 Now, this will mean not equal. 146 00:09:31,150 --> 00:09:33,400 And not not equal type. 147 00:09:35,620 --> 00:09:38,690 And not equal value. 148 00:09:39,020 --> 00:09:42,480 OK, so it may not equal time and not equal value. 149 00:09:42,850 --> 00:09:43,200 Good. 150 00:09:43,330 --> 00:09:44,770 So what, you think this will happen? 151 00:09:44,950 --> 00:09:47,230 So obviously here we have the same type. 152 00:09:47,800 --> 00:09:51,790 The type is a correct in six is not equal to five. 153 00:09:51,820 --> 00:09:56,200 Well, that should be true because six is not equal to five. 154 00:09:56,410 --> 00:09:58,330 And we have the same numbers. 155 00:09:58,510 --> 00:09:59,950 Same type of numbers. 156 00:10:00,160 --> 00:10:00,460 Right. 157 00:10:00,730 --> 00:10:02,150 OK, let's do one more. 158 00:10:02,200 --> 00:10:06,780 I mean, with the same operator six not equal to six, would you think this will happen? 159 00:10:07,090 --> 00:10:11,170 So we saying that this is a from a type number and it's not equal to. 160 00:10:12,590 --> 00:10:14,120 Six, well, that's not true. 161 00:10:14,150 --> 00:10:15,950 Six is equal to six, right? 162 00:10:16,310 --> 00:10:19,730 So here we can compare it to something else. 163 00:10:22,160 --> 00:10:25,810 And it will say true, why will say true? 164 00:10:25,820 --> 00:10:30,170 Well, six is not equal to something, something is a string. 165 00:10:30,170 --> 00:10:31,600 And first things first. 166 00:10:31,910 --> 00:10:34,670 This will check if the time is a number. 167 00:10:34,790 --> 00:10:38,510 So six is a number, string is not string. 168 00:10:39,080 --> 00:10:39,980 This one is string. 169 00:10:39,980 --> 00:10:40,850 So it's not a number. 170 00:10:40,850 --> 00:10:41,920 So it's not equal time. 171 00:10:42,050 --> 00:10:44,400 So the first parameter is not satisfied. 172 00:10:44,600 --> 00:10:47,690 And again, six is not even equal to something. 173 00:10:47,780 --> 00:10:48,190 Right. 174 00:10:48,260 --> 00:10:49,400 The value is different. 175 00:10:49,760 --> 00:10:52,020 OK, that is pretty much it. 176 00:10:52,640 --> 00:10:54,140 Well, I can leave that one there. 177 00:10:54,170 --> 00:10:54,950 Don't worry about it. 178 00:10:54,960 --> 00:11:01,820 So you know about the comparison operators and we will talk more about them, the rest of them. 179 00:11:02,610 --> 00:11:02,850 Oops. 180 00:11:03,410 --> 00:11:04,060 In future. 181 00:11:04,340 --> 00:11:07,070 So stay safe and I will see you in the next one.