3 ms·
What about the fact that there isn't a single 'parseInt' function in JS that can reliably only convert number strings to numbers? They each have different quir
by joaohaas 1mo ago
What about the fact that there isn't a single 'parseInt' function in JS that can reliably only convert number strings to numbers?
They each have different quirks (some will parse 'a123' as 123, others will handle scientific notation etc). The only reliable way of doing this is doing a regex followed by parseInt... which is definitely a footgun IMO.
- Izkata 1mo agoUnary "+" returns NaN for strings that don't contain exactly a number (except for empty string which standard type conversion turns into 0). It even works for scientific notation like +'1e3' === 1000.