3 ms·
Not sure why you don't think the missing radix is a "real" bug, there are plenty of real use cases where a leading zero is proper formatting, for example, in sp
by tolmasky 16y ago
Not sure why you don't think the missing radix is a "real" bug, there are plenty of real use cases where a leading zero is proper formatting, for example, in spreadsheets that keep the same number of digits in each cell. Not to mention that since this is all web code there is a good chance this is all user input so anything goes.
- nbpoole 16y agoMy point is that specifying the radix is a best practice: there are still a number of situations where it's unnecessary for properly functioning code (ie: if you aren't using zero-padded numbers). Specifying the radix certainly helps readability, but you can't just do a regex search and say that all the code it finds is buggy. On the other hand, casting Math.random() to an int is wrong unless you're trying to express 0 in an obfuscated way.
- podperson 16y agoAgreed. If you're calling parseInt on a variable it's simply not a bug. parseInt(1) seems like a whole different class of bug to me :-)
- antimatter15 16y agoWell, say you're trying to get an int from .style.top, it'll never have leading zeroes.
- tpope 16y agoThere are also real use cases where octal and hex parsing are desired. To do a search for parseInt\(*[^,]\) and declare all as bugs is myopic.