JavaScript Number parseFloat() method
- Προηγούμενη σελίδα POSITIVE_INFINITY
- Επόμενη σελίδα parseInt()
- Επιστροφή στο προηγούμενο επίπεδο Εκπαιδευτικός Οδηγός Εreference για JavaScript Number
Definition and usage
Number.parseFloat()
The method parses the value as a string and returns the first number.
Note:
If the first character cannot be converted to a number, then returns NaN
。
Leading and trailing spaces will be ignored.
Only returns the first number found.
Instance
Example 1
Number.parseFloat(10); Number.parseFloat("10"); Number.parseFloat("10.33"); Number.parseFloat("34 45 66"); Number.parseFloat("He was 40");
Example 2
Number.parseFloat("40.00"); Number.parseFloat(" 40 "); Number.parseFloat("40 years"); Number.parseFloat("40H") Number.parseFloat("H40");
Syntax
Number.parseFloat(value)
Parameter
Parameter | Description |
---|---|
value | Required. The value to be parsed. |
Return value
Type | Description |
---|---|
Boolean value | If a number is not found, returns NaN. |
Browser support
Number.parseFloat()
Is ECMAScript6 (ES6) feature.
All modern browsers support ES6 (JavaScript 2015):
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Υποστηρίζεται | Υποστηρίζεται | Υποστηρίζεται | Υποστηρίζεται | Υποστηρίζεται |
O Internet Explorer 11 (ή παλιότερη έκδοση) δεν υποστηρίζει Number.parseFloat()
。
- Προηγούμενη σελίδα POSITIVE_INFINITY
- Επόμενη σελίδα parseInt()
- Επιστροφή στο προηγούμενο επίπεδο Εκπαιδευτικός Οδηγός Εreference για JavaScript Number