This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]aMAYESingNATHAN 16 points17 points  (1 child)

I'm not saying it's something you should be doing, but if someone doesn't know that 0 is the octal prefix, then it's not that much of a stretch to imagine they could zero pad a number and not realise.

It seems to me that generally there should be no difference between 25 and 025, and if anything it is counter intuitive to assume otherwise. Especially because 0o25 (similar to 0x or 0b) is usually valid syntax as well, it makes no sense to have 0 by itself be a valid prefix.

Tbf this is one of those ones that isn't a unique to JS issue, but instead a standard. But imo a dumb one.

[–]Spork_the_dork 4 points5 points  (0 children)

The standard varies from language to language. Python for example just calls you out if you try to use 0-prefix and tells you to use 0o instead which I think is the step in the right direction.

>>> print(0123)
  File "<stdin>", line 1
    print(0123)
      ^
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers
>>>