standards deviations
November 23rd, 2007 by Dylan
Last month, Microsoft created a document outlining each of the major browser’s deviations from the ECMAScript 3 standard. The blog entry links to the full 87 page summary which is pretty informative. For example, something as straightforward as parseInt(string, radix) has different behavior across browsers.
When radix is 0 or undefined and the string’s number begins with a 0 digit not followed by an x or X, then the implementation may, at its discretion, interpret the number either as being octal or as being decimal. Implementations are encouraged to interpret numbers in this case as being decimal.
alert(parseInt("08", undefined));
alert(parseInt("08", 0));
alert(parseInt("011", undefined));
alert(parseInt("011", 0));
Output:
IE: alerts 0, 0, 9, 9
FF: same as IE
Opera: alerts 8, 8, 11, 11
Safari: same as IE, FF