WDI Fundamentals Unit 8
Here are some notes on what's been covered in this chapter. Feel free to copy this information and extend it to make your own cheat sheet.
=
operator. First, the expression to the right of the =
is evaluated. Then, this value is assigned to the variable to the left of the =
. Finally, the =
operator evaluates to the value that has just been assigned.x = x + 1
(or its shorthand, x += 1
).x = y
only means that the value that y
had been holding is now also held in x
. It does not imply any lasting relationship between x and y.undefined
.null
, can be passed into a logical operator as an input; based on whether these inputs are either "truthy" or "falsey" and the type of operator you're dealing with, the operator will behave in different ways.Operator | Meaning | True expressions |
---|---|---|
== | Equality | 10 == '10' |
=== | Strict equality | (2 * 5) === 10 |
!= | Inequality | 9 != 10 |
!== | Strict inequality | '10' !== 10 |
> | Greater than | 20 > 10 |
>= | Greater than or equal to | '10' >= 10 |
< | Less than | 10 < 30 |
<= | Less than or equal to | '10'<= 10 |
Logical operators work on Boolean values to produce Boolean results.
AND operator &&
Condition 1 | Condition 2 | Result |
---|---|---|
true | true | true |
true | false | false |
false | true | false |
false | false | false |
OR operator ||
Condition 1 | Condition 2 | Result |
---|---|---|
true | true | true |
true | false | true |
false | true | true |
false | false | false |
NOT operator !
Condition | Result |
---|---|
true | false |
false | true |
We can use parentheses to change the order of operations for logical operators, just like we do in mathematics.
Feeling confident? Let's take what we've learned and apply it to a project.