JS Built-ins
NumberparseFloatbeginner

Number.parseFloat() β€” '3.14' β†’ 3.14

πŸ“– Usage Example
// Parse a string to a floating-point number
Number.parseFloat('3.14')      // β†’ 3.14
Number.parseFloat('3.14abc')   // β†’ 3.14 (stops at first non-numeric)
Number.parseFloat('abc')       // β†’ NaN

Use Number.parseFloat() to convert a string to a decimal number, stopping at the first character that is not part of a valid number.

Number.parseFloat()

Number.parseFloat(string) parses a string and returns a floating-point number. It is the same as the global parseFloat().

Number.parseFloat('3.14')  // β†’ 3.14
πŸ’‘ Hints (1)
  • β€’ `Number.parseFloat` is identical to the global `parseFloat`.