1
00:00:00,440 --> 00:00:05,100
All right, welcome back to Section three, lesson six operators.

2
00:00:05,120 --> 00:00:10,220
So today we're going to talk about how do you do operations in JavaScript?

3
00:00:10,340 --> 00:00:21,080
So operations are basically simple methods for doing mathematical expressions or logical expressions

4
00:00:21,560 --> 00:00:29,870
that can help us determine how something can be true or false or to change some value, mutate some

5
00:00:29,870 --> 00:00:34,580
number or some string into a different value.

6
00:00:34,820 --> 00:00:39,560
So that's called data mutation, where we're going to change the value from one number to another and

7
00:00:39,560 --> 00:00:43,410
we can use some basic mathematical expressions to do that.

8
00:00:44,330 --> 00:00:50,090
So there are many basic JavaScript operators that arithmetic assignment, comparison, logical and type

9
00:00:50,090 --> 00:00:52,300
of and there are others as well.

10
00:00:52,310 --> 00:00:55,520
So we're just going to start with those and look into them.

11
00:00:57,720 --> 00:01:01,490
OK, so those are the ones are going to take a look at it.

12
00:01:01,530 --> 00:01:05,060
So let's jump into examples.

13
00:01:06,360 --> 00:01:11,990
OK, so now we're in our JavaScript and let's just take a basic number, OK?

14
00:01:13,010 --> 00:01:17,660
Let's just take our basic number that we're going to declare and assign of count of zero.

15
00:01:18,650 --> 00:01:20,660
So what can we do with this count?

16
00:01:21,160 --> 00:01:24,170
OK, well, we can reassign it.

17
00:01:24,290 --> 00:01:26,210
We can set it equal to something else.

18
00:01:27,140 --> 00:01:36,380
And let's just go through the standard arithmetic operations so we can do count equals count plus one.

19
00:01:37,580 --> 00:01:41,740
We could also do count equals count minus one.

20
00:01:42,080 --> 00:01:46,420
And so that would be taking zero to one and then taking one back to zero.

21
00:01:47,210 --> 00:01:57,050
We can also do multiplication so we can times that by one we can do a division as well, divide by one

22
00:01:57,830 --> 00:01:59,210
and there are some others as well.

23
00:01:59,210 --> 00:02:00,290
We could do remainder.

24
00:02:00,630 --> 00:02:02,240
This is also called modulo.

25
00:02:02,840 --> 00:02:06,870
So we could do a remainder operation with this.

26
00:02:06,890 --> 00:02:12,070
So this would be if you divide by that number, then it will get you the remainder.

27
00:02:12,380 --> 00:02:14,990
So, you know, one divided by.

28
00:02:16,000 --> 00:02:21,520
To the remainder would still be zero or zero divided by two, the remainder would still be zero.

29
00:02:22,570 --> 00:02:27,150
OK, and then we can do increment.

30
00:02:27,520 --> 00:02:31,840
So if you want to do this, you could just do count plus plus.

31
00:02:31,840 --> 00:02:35,110
And that's going to be the same as count equals count plus one.

32
00:02:36,310 --> 00:02:37,660
You can actually do this.

33
00:02:37,660 --> 00:02:41,260
From the other perspective you could do plus plus count.

34
00:02:41,260 --> 00:02:43,390
There's a minor difference between those two.

35
00:02:44,170 --> 00:02:46,420
So count plus plus is going to add one to it.

36
00:02:46,420 --> 00:02:50,580
But technically this actually inside of a function return.

37
00:02:50,600 --> 00:02:52,570
So this is a very unique case.

38
00:02:53,020 --> 00:02:58,840
This is actually going to return, going to change the count up by one and then it's going to return

39
00:02:58,840 --> 00:03:00,670
the final value in this example.

40
00:03:00,670 --> 00:03:05,480
It actually returns the value and then it adds the one after it returns it.

41
00:03:05,510 --> 00:03:08,710
So you actually don't get the same return value in either case.

42
00:03:09,790 --> 00:03:12,310
OK, but both of these do count plus one.

43
00:03:12,310 --> 00:03:14,500
So they're the same functionally as this one right here.

44
00:03:14,960 --> 00:03:17,550
OK, all right.

45
00:03:17,560 --> 00:03:18,940
And then there are a few others.

46
00:03:18,940 --> 00:03:22,920
So we could do count equals minus count.

47
00:03:23,230 --> 00:03:26,230
So this would be get the negative of that option.

48
00:03:27,150 --> 00:03:27,560
OK.

49
00:03:28,110 --> 00:03:34,770
Oh, I guess corollary to this, you could do count minus, minus or minus minus count.

50
00:03:35,430 --> 00:03:40,920
OK, so that goes that does count minus one in the same exact way as this does count plus one.

51
00:03:41,190 --> 00:03:45,370
OK, you can also do exponents so we can do exponents.

52
00:03:45,370 --> 00:03:50,140
So if we do that does count to the power of.

53
00:03:50,160 --> 00:03:52,020
So we can do count to the power of two.

54
00:03:53,510 --> 00:03:59,240
OK, so these are the arithmetic operations I'm going to call this right here.

55
00:04:02,020 --> 00:04:03,100
Arithmetic

56
00:04:05,350 --> 00:04:08,770
operations, OK, operators.

57
00:04:11,330 --> 00:04:18,180
But there are many more than this, so let's take a look at comparison operators next day.

58
00:04:18,220 --> 00:04:24,650
So there are some comparison operators now with comparison operators, you're going to be doing some

59
00:04:25,130 --> 00:04:26,900
logical comparisons.

60
00:04:26,910 --> 00:04:32,150
You're going to find out whether something is the same as something else.

61
00:04:32,570 --> 00:04:39,110
OK, so this expression is going to resolve as either true or false.

62
00:04:40,160 --> 00:04:44,670
So you can see count equals zero.

63
00:04:44,990 --> 00:04:51,170
Now, this is going to be a check to see whether it is true or false.

64
00:04:51,350 --> 00:04:54,410
OK, and that's called a boolean value.

65
00:04:54,920 --> 00:04:55,180
OK.

66
00:04:55,250 --> 00:04:57,500
It's to find out whether it's a boolean value.

67
00:04:58,220 --> 00:05:01,250
You can do the same thing, but slightly different.

68
00:05:02,840 --> 00:05:04,490
Let's just copy the first part of this.

69
00:05:05,450 --> 00:05:10,400
You can do the same thing, but slightly different and say not equal to zero.

70
00:05:10,560 --> 00:05:14,960
And there's another actually sorry, this is only one exclamation.

71
00:05:14,990 --> 00:05:19,100
So the way that you do not equal to is exclamation equals zero.

72
00:05:20,560 --> 00:05:25,520
OK, and then there's a strict equal also called congruence.

73
00:05:25,670 --> 00:05:28,970
So you do count equals equals equals zero.

74
00:05:29,000 --> 00:05:35,720
So what this will do is it will check to see that their values are the same, not just the same, but

75
00:05:35,720 --> 00:05:38,590
there's also a sameness in the type.

76
00:05:38,720 --> 00:05:40,400
So they're the same data type.

77
00:05:41,150 --> 00:05:49,520
So that means if this was actually the string zero, so this would actually be a string like, you know,

78
00:05:49,520 --> 00:05:56,840
as you would have in a word, it would not actually be true that it would be district equal to zero.

79
00:05:57,140 --> 00:06:03,880
OK, you can do this, not equal, and that is with the exclamation equals.

80
00:06:04,760 --> 00:06:10,250
So in the case where you were to check whether they were the same data type, if they were not the same

81
00:06:10,250 --> 00:06:13,910
data type or the value was different, this would be seen as true.

82
00:06:14,120 --> 00:06:21,200
And then the next one is you're probably more familiar with count greater than zero and count less than

83
00:06:21,200 --> 00:06:21,590
zero.

84
00:06:22,430 --> 00:06:25,940
OK, and then there are a few more of those.

85
00:06:28,040 --> 00:06:37,400
So there's count greater than or equal to zero and there's count less than or equal to zero.

86
00:06:37,830 --> 00:06:44,810
OK, and obviously you can have any expression on the left side of this and any expression on the right

87
00:06:44,810 --> 00:06:45,500
side of this.

88
00:06:45,680 --> 00:06:48,410
OK, so it's a little bit simpler than simply an assignment.

89
00:06:49,010 --> 00:06:51,050
We're not assigning any values here.

90
00:06:51,050 --> 00:06:53,310
We're not mutating or changing any data.

91
00:06:53,930 --> 00:06:59,360
All we're doing is checking to see whether or not something a relationship between these two values

92
00:06:59,810 --> 00:07:01,140
is true or false.

93
00:07:01,430 --> 00:07:02,660
So that's the difference there.

94
00:07:03,910 --> 00:07:06,670
There are a lot of other types of operations we could do.

95
00:07:06,700 --> 00:07:11,500
I'm just going to show you a few others what are called the assignment operators.

96
00:07:12,760 --> 00:07:17,350
So these assignment operators can kind of shortcut some of the other things that we've been looking

97
00:07:17,350 --> 00:07:17,570
at.

98
00:07:18,340 --> 00:07:22,100
So first things, first count equals zero.

99
00:07:22,300 --> 00:07:28,610
That is our regular old assignment operator if we want to do an addition assignment.

100
00:07:28,840 --> 00:07:33,280
So that's combining the addition operator and the assignment operator.

101
00:07:34,060 --> 00:07:41,800
Then we can do count plus equals one or any other number, OK, or any other value.

102
00:07:41,890 --> 00:07:45,520
You could do this with strings and you could use this to concatenate strings together.

103
00:07:46,480 --> 00:07:48,010
So that's addition assignment.

104
00:07:48,040 --> 00:07:51,430
So this is the same as count equals count plus one.

105
00:07:52,900 --> 00:07:59,950
And then you can do a subtraction, you could do count minus equals and do the same thing as count equals

106
00:07:59,950 --> 00:08:02,340
count minus one, as you can see up on line five.

107
00:08:04,000 --> 00:08:09,910
And you can do multiplication assignment so you can count eight times equals.

108
00:08:12,850 --> 00:08:16,810
Let's just do that for differences and then you could do a division assignment.

109
00:08:17,230 --> 00:08:19,270
So you count divided equals

110
00:08:21,850 --> 00:08:24,550
and you can do the remainder assignment.

111
00:08:25,390 --> 00:08:27,730
So same thing right here.

112
00:08:30,940 --> 00:08:34,210
And count equals exponentiation assignment.

113
00:08:34,730 --> 00:08:37,090
So you can do just like that.

114
00:08:37,300 --> 00:08:42,940
So this is the same as count equals count to the power of some other number.

115
00:08:43,450 --> 00:08:43,810
OK.

116
00:08:46,560 --> 00:08:53,670
And there are also a number of others you can look at left shift assignment, bitwise logical assignment

117
00:08:53,670 --> 00:08:54,950
in a number of different things.

118
00:08:55,410 --> 00:09:03,630
So feel free to look at the resources for how you can use some of these other operations.

119
00:09:03,630 --> 00:09:07,690
But these are the ones that you're going to be using most of the time.

120
00:09:07,800 --> 00:09:12,000
There are a few other logical operators that I want to cover real quick.

121
00:09:14,020 --> 00:09:17,830
So these kind of go along with the comparison operators.

122
00:09:19,180 --> 00:09:24,780
You can just one thing you could do is just say our account is greater than zero.

123
00:09:25,510 --> 00:09:29,950
And so these are these are what's called logical operators.

124
00:09:31,060 --> 00:09:43,080
Logical operators count is greater than zero and count is greater than three.

125
00:09:43,480 --> 00:09:46,630
So that means they both have to be true at the same time.

126
00:09:46,840 --> 00:09:48,250
Or we could say less than three.

127
00:09:49,000 --> 00:09:52,120
So both have to be true at the same time for this to be the case.

128
00:09:53,590 --> 00:10:01,180
There's a very similar operation for not and but for so you could say or with the pipe key.

129
00:10:01,660 --> 00:10:07,540
And that is the one that's just to the left of the enter key, just above the right shift on the keyboard.

130
00:10:08,800 --> 00:10:12,730
And you have to you have to make sure you do you have to do a shift on that.

131
00:10:13,240 --> 00:10:18,340
OK, and this means or so you're saying, this one or the other one.

132
00:10:18,700 --> 00:10:24,010
OK, so either of these can be true and then this would result as true.

133
00:10:24,580 --> 00:10:28,560
OK, so those are the basic operators.

134
00:10:28,570 --> 00:10:30,790
There are a few others that you could learn.

135
00:10:31,300 --> 00:10:37,660
String operation is just you know, you can concatenate using the plus which is the addition operator

136
00:10:38,020 --> 00:10:46,290
and there are a few others as well, but that is it for the basics of JavaScript operators.

137
00:10:46,300 --> 00:10:47,980
And we'll see you in the next lesson.
