provided by: 
Originally published at Internet.comJScript has a limited set of data types: Number, String, Boolean, and Object. The JScript interpreter works behind the scenes to coerce, or convert, data stored in variables into one of its native types using a standard set of rules (see section nine of the ECMAScript Language Specification). For example, the listing below uses the typeof operator to demonstrate that one variable can manage several data types (you can view the sample here) var a; a = 5; // typeof(a) returns 'number' a = "five"; // typeof(a) returns 'string' a = false; // typeof(a) returns 'boolean' a = new String("");// typeof(a) returns 'object'
The key benefit the JScript interpreter provides is that is makes code easier to write since it performs data type conversions for you. The key drawback is that the JScript interpreter can end up working against the developer in situations like the one I demonstrated last week (where the interpreter seems to unexpectedly change a data type from one type to another) - here's the code again: a = 1; b = "1"; a += b; // what is the value of a?
If you guessed that the value of a should be two, you're wrong. Based on the data type conversion rules in the ECMAScript standard, JScript evaluates both operands (a and b) and determines that one of them, b, is a String (based on the value that's assigned to b). Since there's a String involved in the operation (+ in this example), JScript converts a into a String and concatenates b to it. The result is that a is 11 - it's not new math, the result is the String "11"...
Read article at Internet.com site