11.12.2012 Views

JavaScript 2.0-The Complete Reference, Second ... - freecodingtutorial

JavaScript 2.0-The Complete Reference, Second ... - freecodingtutorial

JavaScript 2.0-The Complete Reference, Second ... - freecodingtutorial

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Table A-23: Binary Type Operators<br />

Operator Description Example<br />

new Creates a new instance of the<br />

object given by the constructor<br />

operand.<br />

void Effectively undefines the value of<br />

its expression operand<br />

var today = new Date();<br />

alert(today);<br />

var myArray = [1,3,5];<br />

myArray = void myArray;<br />

alert(myArray);<br />

// shows undefined<br />

Also included in the type operators is the property-accessing operator. To access a property<br />

property of an object object, the following two syntaxes are equivalent:<br />

object.property<br />

object["property"]<br />

Note that the brackets above are ―real‖ brackets (they do not imply an optional component).<br />

Comma Operator<br />

<strong>The</strong> comma operator allows multiple statements to be carried out as one. <strong>The</strong> syntax of the<br />

operator is<br />

statement1, statement2 [, statement3] ...<br />

If used in an expression, its value is the value of the last statement. <strong>The</strong> comma is commonly<br />

used to separate variables in declarations or parameters in function calls.<br />

Relational Operators<br />

Relational operators, as detailed in Table A-24, are binary operators that compare two like<br />

types and evaluate to a Boolean indicating whether the relationship holds. If the two operands<br />

are not of the same type, type conversion is carried out so that the comparison can take place<br />

(see the section immediately following for more information).<br />

Table A-24: Binary Relational Operators<br />

Operator Description<br />

< Evaluates true if the first operand is less than the second<br />

Evaluates true if the first operand is greater than the second<br />

>= Evaluates true if the first operand is greater than or equal to the second<br />

!= Evaluates true if the first operand is not equal to the second<br />

= Evaluates true if the first operand is equal to the second<br />

!= Evaluates true if the first operand is not equal to the second (and they have<br />

the same type)<br />

= Evaluates true if the first operand is equal to the second (and they have the<br />

same type)<br />

Type Conversion in Comparisons

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!