Operators
Arithmetic Operators:
Arithmetic operators are used to perform arithmetic on numbers:
Example:
txt1 = "Material Name Is";
txt2 = "Clay";
txt3 = txt1 + " " + txt2;
The result of txt3 will be:
Material Name Is Clay
|
Operator
|
Description
|
|
+
|
Addition
|
|
-
|
Subtraction
|
|
*
|
Multiplication
|
|
/
|
Division
|
|
%
|
Modulus
|
|
++
|
Increment
|
|
--
|
Decrement
|
Assignment Operators:
Assignment operators assign values to JavaScript variables.
|
Operator
|
Example
|
Same As
|
|
=
|
x = y
|
x = y
|
|
+=
|
x += y
|
x = x + y
|
|
-=
|
x -= y
|
x = x - y
|
|
*=
|
x *= y
|
x = x * y
|
|
/=
|
x /= y
|
x = x / y
|
|
%=
|
x %= y
|
x = x % y
|
Comparison Operators:
|
Operator
|
Description
|
|
==
|
equal to
|
|
===
|
equal value and equal type
|
|
!=
|
not equal
|
|
!==
|
not equal value or not equal type
|
|
>
|
greater than
|
|
<
|
less than
|
|
>=
|
greater than or equal to
|
|
<=
|
less than or equal to
|
|
?
|
ternary operator
|
Logical Operators:
|
Operator
|
Description
|
|
&&
|
logical and
|
|
||
|
logical or
|
|
!
|
logical not
|