On Aug 23, 3:39 pm, Pops <[EMAIL PROTECTED]> wrote:
> $("start").value -= 1*$("rows").value; // <- WORKS AS EXPECTED
$('start').value is a STRING, but no -= operator is available for
strings, so it converts the value to a number.
> $("start").value += 1*$("rows").value; // <- BUG!!
Aha - .value is a STRING, but operator += IS defined for Strings, so
it uses it and appends to the value.
> To me, that looks look like a JS type casting bug or inclusive
> addition bug?
It's not a bug, but a confusion about how the operators and type
conversion apply. IMO += should not be overloaded for strings, to
avoid exactly this type of problem. The fact that SOME of the built-in
types have special operator overloads, but users of the language
cannot overload any operators (except, indirectly, toString()), is a
language design flaw, IMO.