![]() |
|
||||||
OPERATORS, IF AND IF/ELSENow is a good time to discuss operators in JavaScript. I am also doing to discuss If and If/Else statements because this is when you are going to use many of these operators. There are several types of operators, and they are listed and described below: Arithmetic Operators: These are they symbols used to calculate values.
In arithmetic conditions, JavaScript follows the order of operations. I think in grade school they taught it as something like, "Please Excuse My Dear Aunt Sally."
It is useful to be aware of the order of operations when working with more than 2 numbers. Here is an example of what I mean: Relational Operators: These are used when comparing one or more items and will return a Boolean expression.
Logical Operators: used to compare two or more simple conditions at the same time.
Something to go along with the logical operators are what are called, "Truth Tables." Truth tables show all possibilities for logical operators when looking at conditions.
Compound Conditions: This is just where you combine two or more simple conditions with a logical operator. Example: INCREMENT OPERATOR:To say, x = x + 1: ++x; x++; Say you took: y = x++; What's going to happen? y will = x and then x will = x + 1. Say you took y = ++x; What's going to happen? x will = x + 1 then, y = x. DECREMENT OPERATOR:To say, x = x - 1: --x; x--; If you took y = x--; What will happen? y will = x and then x will = x - 1. If you had y = --x; What happens? x will = x - 1; then y will = x. Not as confusing as you might think. This will help you when using increment and decrement operators to know the value of your variable through the process of the program.
No Comments for this page. |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||