JS Built-ins
NumberparseFloatintermediate

Number.parseFloat() β€” stops at non-numeric characters

πŸ“– 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() β€” Partial Parse

Number.parseFloat parses as far as it can, stopping at the first non-numeric character.

Number.parseFloat('123abc')  // β†’ 123
πŸ’‘ Hints (1)
  • β€’ Parsing stops at the first character that cannot be part of a float.