
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
128
|
Chapter 5: Operators
If the operands are strings, the less-than operator returns true if operand1 comes
before
operand2 in the Unicode character set; otherwise, it returns false:
"a" < "z" // true; lowercase "a" comes before lowercase "z"
"A" < "a" // true; uppercase letters come before lowercase
"Z" < "a" // true; uppercase letters come before lowercase
"hello" < "hi" // true; "e" comes before "i"
For further string comparison details, see “Character order and alphabetic compari-
sons” in Chapter 4.
The Greater-Than Operator
The greater-than operator takes the general form:
operand1 > operand2
If the operands are numeric, the greater-than operator returns the Boolean true if
operand1 is mathematically larger than operand2:
5 > 6 // false
5 > 5 // false; they are equal, but 5 is not greater than 5
–3 > –6 // true; –3 is greater than –6.
–6 > –3 // false; –6 is not greater than –3.
If the operands are strings, the greater-than operator returns true if operand1 comes
after
operand2 in the Unicode character set; otherwise, it returns false:
"a" > "z" // false; lowercase "a" comes before lowercase "z"
"A" > "a" // false; uppercase letters don't come after lowercase
"Z" > "a" // false; uppercase letters don't come after lowercase
"hello" > "hi" // false; "e" comes before "i"
For further string ...