pub fn string_to_number(s: &str) -> f64Expand description
Convert a JavaScript string to a number according to ECMAScript ToNumber.
The string is first trimmed of leading and trailing whitespace. Then it is parsed as a numeric literal:
- Empty string → 0
- “Infinity”, “+Infinity”, “-Infinity” → Infinity, +Infinity, -Infinity
- “0x” or “0X” prefix → hexadecimal
- “0o” or “0O” prefix → octal
- “0b” or “0B” prefix → binary
- Otherwise → decimal (with optional sign, exponent)
- Invalid → NaN