The number type of JS
JS has only one type of number, and all the numbers in the number.js are of this type. Include integer 1,-2,3, floating-point number 1.1,-1.2,1.3 belong to this type. So, in JS, the typof integer or TYPOF floating-point number returns number.
Type conversion of JS
There are three commonly used functions in JS to convert non-numeric types to numeric types, number (), Parseint,parsefloat (), and can be lowered directly in the window scope, using:
Anumber = number (Notnumber);
AInt = parseint (Notnumber);
Afloat = parsefloat (Notnumber);
From the function name, you can see the function to:
Number (): You can convert non-numeric to numeric, the result may be an integer, or it may be a floating-point
parseint (): Convert a non-numeric type to a number, convert the result to an integer, direct rounding, no rounding operation
Parsefloat (): Converts a non-numeric type to a numeric type. The conversion result is a floating point number.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
JavaScript number types