All right, welcome back here on lesson seven, boolean logic, Boolean is named after a man, George
Bush.
He was an old mathematician in the eighteen hundreds and he really kind of defined the terms that we
have for logic.
And that's used a lot in mathematics and use fantastically in programming.
It's used all over the place in programming.
Basically, he invented and worked on very primitive computers and algebraic problems, boolean logic.
So a couple of different operators we have.
And and that's and that means both of the values to the left and right of this operator have to be true
or means if one of the values or both to the left and right of this are true, it will continue.
The exclamation mark is usually is paired with other operators.
So like exclamation equals would be not equals.
As you can see here, we're not exactly equal to.
And then you have these others as well, these are other comparison operators, this is similar to work
in Group two or the exactly the same as this is the same value and data type.
This is less then and less than or equal to the left.
Carrott right is right here is greater than greater than or equal to.
So the value on the left is greater than the value on the right.
And they have some bitwise operators.
We can look at these as well.
We don't use bitwise operators very often in JavaScript, but there they operate on a bit string, a
bit array or binary numeral at the level of individual bits.
So it's it's kind of what computer programming does at a more basic level.
And you can perform those on binary numbers as well, too.
OK, so let's take a look at some values in code.
All right, so now in JavaScript, let's just focus on some of the ones we use most most often.
So let's just say let the equation equal five is greater than two.
And so we could just check to see, is this true, so we could just along the variable itself
equation and then we'll see, hey, is five greater than two?
And the answer is yes, it is true.
Now, if we check, is it less than two, that's false.
Five is not less than two, is it less than or equal to two?
No, that's false.
Is it less than or equal to five?
Yes, five is less than or equal to five, because five is equal to five is five less than five.
No, that's false.
So you could say you could use these comparison operators to check something less than or less than
or equal to something.
And then you can use five is greater than two and
two is greater than one.
OK, so let's just see how this goes.
Let's just read this right now.
True.
OK, so five is greater than two, that's true.
Two is greater than one.
That's true.
Also, OK, these are both true and this says both have to be true.
And so this is true.
And this is true.
So if we change this one to four and we check it again.
It's false because, too, is not greater than four, so since this site is true, this site is false,
it's true and false, which means the total is false.
There's any false value in there, then the whole thing is false.
OK, because that's the final value that's being checked.
Rechecking, checking.
Is this true?
Yes.
And is this true now?
OK, so are they both true?
No, that's the real question.
Now, if he chooses to or then one of them being true is OK, as you can see, that's true.
What if we make them both false?
OK, we make them both false, then boom, neither one is false or is asking.
Is at least one of these true?
That's what Gore is asking.
OK, so that's how you get and and or there's also not we can say this
five equals five.
OK, is that true.
Yes.
Five is equal to five.
You can also do ten divided by two is five.
Exactly the same is ten.
Divided by two.
Yes, because ten divided by two is five.
What if we say is not equal to.
Let's check that.
No, that's false.
Five is not not equal to five.
So let's try again with let's change this value to four.
Is four different then.
Ten divided by two.
Yes, the answer is true.
There you go.
So that's how you can use equals to say is the same as not equals with the not symbol to say is not
the same as.
OK, just beware.
Obviously, you might have gotten a little tripped up when I was saying, hey, is this not the same
as the other thing.
And you say yes or no humans, especially in English, have a hard time asking and answering questions
which involve not only is this not the same, what are you supposed to say to that?
Yes or no?
So we keep it simple in JavaScript, true or false, but still beware of using not just so you don't
get confused with what you need to do.
OK, all right.
So that is the basics of boolean logic in JavaScript and we'll catch you in the next video.