[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Datatype Conversion
At 6:48 AM 1/12/96, Lourdes Yero wrote:
>This example work fine with netscape 2.0beta4
>With Netscape 2.0beta5 DON'T WORK !!!!
[omitted]
> total = 0 + form.ent1.value + form.trav1.value
There was an incompatible change introduced at 2.0b5 to match JavaScript
behavior to Java behavior; there's a separate way to handle this case which
is backwards compatible with 2.0b4 (and 2.0b3).
Here's the relevant discussion of this by Brendan Eich:
>In the course of standardizing LiveScript into JavaScript with Sun, we've
>decided to make an incompatible change: formerly, you could convert from a
>string containing a numeric literal (possibly with leading and trailing
>white space) to a number by saying '0 + str'.
>But that's incompatible with Java's overloading of the + operator for string
>concatenation: in Java, '0 + str' where str contains "123" should produce
>"0123", a string. That's how Java behaves, and in 2.0b5 that is also how
>JavaScript behaves.
>So, to convert your scripts to work with both 2.0b4 JavaScript and 2.0b3
>LiveScript, as well as with the soon-to-be-released 2.0b5 JavaScript, you'll
>need to change all '0 + str' conversions to 'parseFloat(str)'.
>If you want to convert an integral numeric literal string, you can call
>'parseInt(str[, radix])' where the radix argument (optional in 2.0b5) is 0
>for C-like rules (leading "0x" => hex, leading "0" => octal, else decimal)
>or the base to use when converting digits.
Hope this helps.
Frank
--
Frank Hecker Pre-sales tech support, Netscape field sales group
hecker@netscape.com http://home.netscape.com/people/hecker/index.html