4 ms·
^ because: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt https://developer.mozilla.org/en-US/docs/Web/JavaScript/Ref
by Groxx 3y ago
^ because: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
> The parseInt() function parses a string argument and returns an integer of the specified radix (the base in mathematical numeral systems).
Surprisingly, if you put garbage in, you get garbage out.
- marcosdumay 3y agoThe garbage obviously being the language's std library.
- Groxx 3y agonah. just type coercion. Why would you parse a float? Parsing is for strings. Converting a float to an int is done with stuff like `Math.floor`.
- xigoi 3y ago> Why would you parse a float? You wouldn't, which is why it should produce an error.
- deleted 3y ago[deleted]
- Groxx 3y agoWhich would be changing the paradigm away from implicit coercion, yes. That would make it a different, entirely hypothetical, ill-defined language. A very clear strawman that isn't particularly worth fighting. It would quite possibly be a better language, but it's not a thing you "just do" to solve footguns - it has pretty big effects on the language and ecosystem.