1 00:00:00,820 --> 00:00:07,660 Some more operators, we have unary operators, so let's say we have Vergès equals nine. 2 00:00:08,820 --> 00:00:14,890 How would I change Vare, let's have I equal to minus nine? 3 00:00:15,360 --> 00:00:22,200 Well, your first instinct is to go minus nine, but if there's a relationship between G and I, we 4 00:00:22,200 --> 00:00:27,040 would say you can just have minus G as the negative version of G. 5 00:00:27,420 --> 00:00:33,630 Now that little minus in front is called a unary operator performs an operation on one thing, which 6 00:00:33,630 --> 00:00:35,190 is in this case, G. 7 00:00:35,820 --> 00:00:39,570 You can of course just have that totally alone as minus G. 8 00:00:40,820 --> 00:00:46,700 Now, that doesn't replace gas, always nine minus G is just used in its own context. 9 00:00:47,600 --> 00:00:49,580 So that's a unary operator. 10 00:00:49,940 --> 00:00:50,570 What else have we got? 11 00:00:50,570 --> 00:00:52,370 We've got a compound operator. 12 00:00:52,550 --> 00:00:59,960 If I want to add one to I, for example, I could say I equals I plus one. 13 00:01:01,030 --> 00:01:05,910 Seems straightforward, so we take the old version of I add one to it and then put it back into I, 14 00:01:06,550 --> 00:01:10,170 but as a shorthand way of doing it, and that's plus equals one. 15 00:01:10,720 --> 00:01:17,080 So what it do is recognize that plus equals wants you to take I and then add whatever number you've 16 00:01:17,080 --> 00:01:18,880 put on the right hand side to I. 17 00:01:19,540 --> 00:01:22,840 Same works in reverse ie minus equals one. 18 00:01:23,530 --> 00:01:27,310 So if we run all this we should come back to the answer of minus nine. 19 00:01:28,660 --> 00:01:32,240 So minus eight and we come back to minus nine. 20 00:01:33,040 --> 00:01:35,610 Simple enough, what else have we got here? 21 00:01:35,620 --> 00:01:37,870 We got logic, logic, logic, logic. 22 00:01:38,470 --> 00:01:38,950 So. 23 00:01:40,190 --> 00:01:46,940 You wouldn't have this statement sitting alone I equals equals g for a start, you'd use it to check 24 00:01:46,940 --> 00:01:47,450 something. 25 00:01:47,900 --> 00:01:55,400 In this case it's checking if I is equal to G and when it says equal to it means exactly. 26 00:01:55,790 --> 00:01:57,320 Number one, is it an integer? 27 00:01:57,860 --> 00:01:59,570 Number two, is it the same value. 28 00:02:00,620 --> 00:02:04,880 You've got to be careful when you're checking if things are equal because if you have a double that's 29 00:02:04,880 --> 00:02:06,800 a nine and you have an integer that's a nine. 30 00:02:07,190 --> 00:02:08,810 In some languages they're equal. 31 00:02:08,810 --> 00:02:12,020 In other languages, they're not in JavaScript. 32 00:02:12,320 --> 00:02:17,870 If you have an integer nine and a string nine and use two equals, they'll be equal. 33 00:02:18,500 --> 00:02:22,460 But if you use three equals, they will not be equal because they are different types. 34 00:02:23,270 --> 00:02:29,300 So you've got to be careful with comparison strings and always check, always, always check that the 35 00:02:29,300 --> 00:02:31,460 comparison is what you expect it to be. 36 00:02:32,050 --> 00:02:34,550 So let's move on with some more comparison operators. 37 00:02:35,060 --> 00:02:37,100 Let's have I not equal to. 38 00:02:38,300 --> 00:02:42,140 So if I is not equal to G, this will return true. 39 00:02:42,500 --> 00:02:49,550 If it is equal to G, it will return false as in it's the reverse of this first one and then we have 40 00:02:49,550 --> 00:02:50,690 a whole bunch of others. 41 00:02:50,690 --> 00:02:55,370 I is less than g we have I is more than G. 42 00:02:57,080 --> 00:02:59,960 I is less than or equal to G. 43 00:02:59,990 --> 00:03:04,520 And can you guess the last one is greater than or equal to G. 44 00:03:05,480 --> 00:03:13,340 So these last to include the value that that's the flipping point of that statement, these two don't 45 00:03:13,340 --> 00:03:14,780 include it, so. 46 00:03:15,930 --> 00:03:21,990 If I was one and she was one, that's not true, that's not true, that is true. 47 00:03:22,650 --> 00:03:23,790 And that's true. 48 00:03:24,270 --> 00:03:30,810 And that's true because we also have equals as part of those greater than or less than statements or 49 00:03:30,810 --> 00:03:31,980 logic operators. 50 00:03:33,200 --> 00:03:36,980 OK, now we have what else do we have here? 51 00:03:38,210 --> 00:03:39,960 Oh, I have a little example for you. 52 00:03:40,280 --> 00:03:42,310 That's Havar equals true. 53 00:03:42,820 --> 00:03:43,670 So this is a boolean. 54 00:03:43,670 --> 00:03:44,750 It's either true or false. 55 00:03:44,990 --> 00:03:54,140 If I want to print the opposite statement of E, I would have print not e exclamation mark means not. 56 00:03:55,040 --> 00:03:58,370 So if we run that, we should get a printed force and we do. 57 00:04:00,060 --> 00:04:03,460 Okay, so those cover a whole bunch of operators. 58 00:04:03,740 --> 00:04:05,060 Let's grab your homework. 59 00:04:05,090 --> 00:04:06,500 Oh, you're in luck. 60 00:04:06,860 --> 00:04:08,480 There is no homework this time. 61 00:04:08,840 --> 00:04:09,860 Congratulations.