Success lies in persistence, giving yourself this sentence;
Today, we review the numerical conversion methods of the two data types: parseint and parsefloat.
Compared to number () method, the two methods of parse are relatively diligent, from left to right, and number is a comprehensive analysis;
Can understand so parseint, he compared local tyrants, in the conversion value, from left to right, encountered non-digital time to stop the conversion, the back of the data are all thrown away;
But parseint is still relatively clever, when the value is preceded by a space, one or more 0 of the time, or will be successfully converted to an integer value, var num1 = parseint (' 0000200 ')//200
And parsefloat, the comparison "thrifty" encountered the decimal point (the first decimal point) or can continue to parse the future
Using both of these methods, we can determine whether a numeric value is not an integer:
var num = 109.88;
if (parseint (num) = = parsefloat (num)) {
Alert (num+ ' is an integer ');
}else{
Alert (num+ ' is decimal ')
}
Data type Review PARSEING&PARSEFLOAT--JS study notes 2015-6-2 (46th day)