August 7, 2012

Data type conversion

JavaScript is a dynamic type language, this means that you can whenever change the type of variables by assigning a different value which is of a different type. This aspect of the language is good because it gives to the programmer the liberty to do everything he wants, but sometimes this liberty can  bring some confusion when working with variables of a specific type and treating them as another data type. This can happen when reading the value of an HTML input and treat it as a number for example, it is needed to convert the desired variable to the desired data type.