Hallo So long,
Eigentlich hast Du recht und mir treibst die Schamesröte ins Gesicht <G>.
Coercion
The JScript interpreter can only evaluate expressions in which the data types of the operands are the same. Without coercion, an expression that attempts to perform an operation on two different data types (a number and a string for example) would produce an erroneous result. But that is not the case with JScript.
JScript is a loosely-typed language. This means its variables have no predetermined type (as opposed to strongly typed languages like C++). Instead, JScript variables have a type that corresponds to the type of value they contain. A benefit of this behavior is that it provides you with the flexibility to treat a value as if it were of another type.
In JScript, you can perform operations on values of differing types without fear that the JScript interpreter will raise an exception. Instead, the JScript interpreter automatically changes (coerces) one of the data types to that of the other, then performs the operation. For example:
Operation Result
Add a number and a string The number is coerced into a string.
Add a boolean and a string The boolean is coerced into a string.
Add a number and a boolean The boolean is coerced into a number.
Consider the following example.
var x = 2000; // A number.
var y = "Hello"; // A string.
x = x + y; // the number is coerced into a string.
document.write(x); // Outputs 2000Hello.
To explicitly convert a string to an integer, use the parseInt Method. To explicitly convert a string to a number, use the parseFloat Method. Notice that strings are automatically converted to equivalent numbers for comparison purposes, but are left as strings for addition (concatonation).
<
Jaja, JScript, shon klar...
cu
stw