HTML and CSS Reference
In-Depth Information
Table G-6 Operator Types (continued)
Type
Operator
Name
Description
Example
Comparison
55
Equal
Returns true if operands are equal
if (a 55 b) {
Not equal
Returns true if operands are not equal
! 5
if (a ! 5 b) {
>
Greater than
Returns true if the left operand is greater than the
right operand
if (a > b) {
<
Less than
Returns true if the left operand is less than the right
operand
if (a < b) {
> 5
Greater than or
equal
Returns true if the left operand is greater than or
equal to the right operand
if (a > 5 b) {
< 5
Less than or equal
Returns true if the left operand is less than or equal
to the right operand
if (a < 5 b) {
555
Equal (no type
conversion done)
Returns true if operands are equal and their types
are the same
if (a 555 b) {
! 55
Not equal (no type
conversion done)
Returns true if operands are not equal or their types
are the same
if (a ! 55 b) {
in
in
Returns true if the property is found as a property
member of the object
(property in object)
instanceof
instanceof
Returns true if the datatype matches the object
(datatype instanceof object)
Conditional
?:
If?then:else
Performs an inline if-then-else and assigns one of
two possible values
Ret 5 (test 55 true) ? “It's
true” : “It's false”
Expression Control
void
Return a void
Sets a variable to an undefined state
ret 5 void
Logical
&&
And
Returns true if both the left operand and the right
operand return a value of true, otherwise it returns
a value of false
if ((a < b) && (c > d)) {
||
Or
Returns true if either the left operand or the
right operand returns a value of true; if neither
operand returns a value of true, then the expression
containing the || (or) operator returns a value of false
if ((a < b) || (c > d)) {
!
Not
Returns true if an expression is false and returns
false if an expression is true
if (!(a < b)) {
Multiple Evaluation
,
Evaluate/Return
right 1
Evaluates two expressions and returns the
second one
Ret 5 (x- -, z) * (y- -, q)
Object
new
New object
Creates a new object
CD 5 new Album
delete
Remove an object
property
Removes a single property of an object
delete CD
String
1
Concatenation
Combines two strings
lang 5 “Java” 1 “Script”
15
Concatenates
Concatenates the value of the right operand to the
value of the left operand and assigns a new value to
the left operand
Lang 15 “Script”
Type Identification
typeof
Return type
Returns the data type of the operand
ret 5 typeof(CD)
Order of Precedence
Unless parentheses/brackets/dots dictate otherwise, reading from left to right in
an expression, all negation/increment/misc are performed first, then all multiply/divide/
modulo, then all addition/subtraction, then all comparison, then all equality/identity, then all
logical and, then all logical or, and then all assignment operators. The order of precedence
is summarized in Table G-7.
Search WWH ::




Custom Search