Operators


Operators join expressions together. This means ands, or, but, math, etc. Here is a list of operators.
Operators (x is initially = 11)
OperatorMeaningExampleResultReason
%Modulusx = x % 5x = 111/5=2 with 1 rem.
++incrementx = x++x = 11++ after a var is applied after asignment
++incrementx = ++xx = 12++ before a var is applied before assignment
--decrementx = x--x = 11same as x = x++
--decrementx = --xx = 10same as x = --x
-negationx = -xx = -11turns pos. to neg. and vice versa
+additionx = x + x x = 2211 + 11 = 22


Operator Precedence (from lowest to highest)
OperatorSyntax
comma,
assignment=, +=, -=, *=, /=, %=
conditional?;
logical or||
logical and&&
equaily==, != (not equal)
relational<, <=, >, >=
mathematical+, -, *, /, %
unary!, -, ++, --
call()


Asignment Operators
AssignmentMeaning
x = ythe value of y is assigned to x
x += yx = x + y
x -= yx = x - y
x *= yx = x * y
x /= yx = x/y
x %= yx = x % y


Comparison Operators
OperatorExampleMeaning
== x == yx equal to y
!=x != yx is not equal to y
<x < yx less than y
>x > yx greater than y
<=x <= yx less than or equal to y
>=x >= yx greater or equal to y

That is all for JavaScript Basics. The next section is Event Handlers
Back Homepage JavaScript Basics Event Handlers