Today, when I was looking at jquery, I used the parsefloat (the first parameter, 10), I didn't know what the second parameter meant, so I looked it up on the internet, so I forgot to turn it down later.
Definition and Usage: the parsefloat () function resolves a string and returns a floating-point number.
Syntax: parsefloat (String), parameter string is required, representing the string to be parsed
Return value: Returns the parsed number
Precautions:
1. The opening and closing spaces are allowed.
2. If the first character of a string cannot be converted to a number, then parsefloat () returns NaN
3. If you want to parse only the integer part of a number, use the parseint () method.
4. Only the first number in a string is returned.
Attached examples:
<script type= "Text/javascript" >
document.write (parsefloat ("10"))
document.write (parsefloat ("10.00"))
document.write (parsefloat ("10.33"))
document.write (Parsefloat ("34 45 66"))
document.write (parsefloat ("60"))
document.write (parsefloat ("Years"))
document.write (parsefloat ("He was 40"))
</script>
Output in turn:
10
10
10.33
34
60
40
NaN
Here's a second question: What does 10 in parsefloat (the first argument, 10) mean
The second parameter of the parsefloat represents the binary of the conversion, and 10 translates to a 10 binary.