Let me dive into the ECMA specification. I have included section numbers so you can reference.
11.8.2 The operator is greater than the operator (>)
RelationalExpression Production: RelationalExpression> The Shift expression is evaluated as follows:
- Let lref be the result of evaluating RelationalExpression.
- Let lval be GetValue (lref).
- Let rref be the result of evaluating the Shift expression.
- Let rval be GetValue (rref).
- Let r be the result of an abstract relational comparison rval <lval with LeftFirst set to false. (see 11.8.5).
An important part of this is abstract relational comparison. It is determined:
11.8.5 Abstract Relational Comparison Algorithm
The toPrimitive function toPrimitive first be called on objects. Although this is biased to return Numbers, if possible, strings can also be retrieved. As soon as this happens, the following will be considered:
but. If py is a px prefix, return false. (The string value of p is a prefix of the value of String q, if q can be the result of concatenating p and some other string r. Note that any String is a prefix in itself, since r can be an empty string.)
b. If px is the py prefix, return true.
from. Let k be the smallest non-negative integer such that the character at position k inside px differs from the character at position k inside py . (There must be a k, since neither String is a prefix of another.)
e. Let m be an integer that is the value of the code unit for the character at position k within px. e. Let n be an integer that is the value of the code unit for the character at position k inside py. e. If m <n, return true. Otherwise, return false.
This means that the first character in the string different from the other will be checked. As Esailija pointed out, the IE toString() function returns a slightly different line to a different line than other browsers, resulting in a different comparison.
This distinction between browsers seems valid, as indicated here:
15.2.4.4 Object.prototype.valueOf ()
When the valueOf method is called, the following steps are performed:
- Let O be the result of calling ToObject, passing this value as an argument.
- If O is the result of calling the Object constructor with the host object (15.2.2.1), then a. Return either O or another value, for example, the host object is initially passed to the constructor. The specific result that is returned is determined by the implementation.
- Refund O.