2 ms·
Octal is sneakier than hexadecimal, especially if the values are from user input. ['07', '08', '09'].map(val => parseInt(val)) // => [7, 0, 0]
by mseepgood 4y ago
Octal is sneakier than hexadecimal, especially if the values are from user input.
['07', '08', '09'].map(val => parseInt(val))
// => [7, 0, 0]
- benatkin 4y agowas ['07', '08', '09'].map(val => parseInt(val)) // => [7, 8, 9]
- jakear 4y agoHasn't been an issue in around a decade: https://developer.mozilla.org/en-US/docs/web/javascript/reference/global_objects/parseint#browser_compatibility https://developer.mozilla.org/en-US/docs/web/javascript/refe...
- deleted 4y ago[deleted]
- benatkin 4y agoPlus there's this if you really want to support old browsers: https://github.com/zloirock/core-js/blob/ce52fdc735c5c809c9e85b2072f92d41b5a3885a/packages/core-js/internals/number-parse-int.js https://github.com/zloirock/core-js/blob/ce52fdc735c5c809c9e...