News for hackers. Stuff that matters.
Re:Another common bug in published code by cracki on Friday April 22, 2011 @11:36AM (#2474381)
that's not a bug, that's a feature.

a questionable feature, yes, but not a real bug.

Re:Another common bug in published code by InclinedPlane on Friday April 22, 2011 @01:43PM (#2474784)
It's a defect, it leads to inconsistent and unpredictable behavior. A better default behavior would have been to use a default radix (base 10) and have an option for auto-detected radix (e.g. strings that begin with 0x). Considering how rare octal formatted integer strings are these days (essentially non-existent) and how much more common 0 prefixed decimal formatted integer strings are, this is definitely not a useful feature.
Re:Another common bug in published code by masklinn on Friday April 22, 2011 @02:38PM (#2474969)
> A better default behavior would have been to use a default radix (base 10) and have an option for auto-detected radix (e.g. strings that begin with 0x).

Note that the option exists (provide `0` as radix). It's just stupid that the default radix is `0` (or `undefined`) and not `10`.

Not to mention, that would put parseInt in line with Number.toString(radix), which (sensibly) defaults to base 10 (side note: I was surprised and impressed to see that Number.toString can handle any base from 2 to 36 included)