JavaScript Editor Free JavaScript Editor     JavaScript Debugger 




Main Page

Previous Page
Next Page

4.3. Operators

JavaScript has a number of operators that you might or might not be familiar with. These include the ever-present == (equals) and != (not equals), to which you have undoubtedly been exposed; there are a number of others. Although some of these operators are familiar, some others might not be as familiar, so Table 4-4 briefly touches upon these.

Table 4-4. JavaScript Operators

Operator

Type

Description

a + b

Arithmetic

Addition

a - b

Arithmetic

Subtraction

a* b

Arithmetic

Multiplication

a / b

Arithmetic

Division

a % b

Arithmetic

Modulus, the remainder to division

++a

Arithmetic

Increment by one

--a

Arithmetic

Decrement by one

a = b

Assignment

Set equal to

a += b

Assignment

Increment by the value on the right

a -= b

Assignment

Decrement by the value on the right

a *= b

Assignment

Multiply by the value on the right

a /= b

Assignment

Divide by the value on the left

a %= b

Assignment

Modulus by the value on the right

a == b

Comparison

Equal to, value

a === b

Comparison

Equal to, value and type

a != b

Comparison

Not equal to

a > b

Comparison

Greater than

a < b

Comparison

Less than

a >= b

Comparison

Greater than/equal to

a <= b

Comparison

Less than/equal to

a && b

Logical

And

a || b

Logical

Or

!a

Logical

Not

a + b

String

String concatenation

a=(condition)?b:c

Comparison

Comparison operator

typeof(a)

Special

Returns a string consisting of the operand type

void a

Special

Suppresses the return of a variable


I'll bet you didn't know that typeof was an operator.


Previous Page
Next Page




JavaScript Editor Free JavaScript Editor     JavaScript Debugger


©