-
Notifications
You must be signed in to change notification settings - Fork 24
Operators
Rohan Singh edited this page Aug 24, 2014
·
30 revisions
The following operators are available, in order of precedence:
Category | Operators |
---|---|
Postfix |
x.y , x[y] , x(y) , x++ , x--
|
Prefix |
-x , !x , ++x , --x
|
Multiplication |
* , / , %
|
Addition |
+ , -
|
Relational |
> , >= , < , <=
|
Equality |
== , !=
|
Conditional And | && |
Conditional Or | || |
Ternary | [[?:
|
Assign |
= , += , -= , *= , /= , %= , [[|>
|
These are the rules the equality operators (==
, !=
) follow:
- Values of different types will never be equal.
-
number
andstring
types of the same value will always be equal. -
object
,array
, andfunction
types will only be equal if they refer to the same instance, not value. -
true
,false
,null
, andundefined
are only equal with themselves.
The relational operators (>
, >=
, <
, <=
) can only be used on number
and string
values. When used on string
values the result allows you to determine sort order.