Re:<3 Deno
by contextnavidad on Sunday February 12, 2023 @06:33PM
(#34768357)
I have my linting setup to force a base on `parseInt`, for the extra characters I do feel it's worth it for the safety.
The extra parentheses is just habit from Prettier formatting :)
Also, no reason to write extra characters just to prevent people from using hexadecimal, it's often convenient and it comes for free!
Octal is more sneaky than hexadecimal, especially if the values are from user input.
['07', '08', '09'].map(val => parseInt(val)) // => [7, 0, 0]
was
['07', '08', '09'].map(val => parseInt(val)) // => [7, 8, 9]
Hasn't been an issue in around a decade: https://developer.mozilla.org/en-US/docs/web/javascript/refe...
Plus there's this if you really want to support old browsers: https://github.com/zloirock/core-js/blob/ce52fdc735c5c809c9e...
Also the parens around a single argument of an arrow function are a superstitious thing suggested by some well-known react developer a while back, I think.