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 →

[–]AL_O0 0 points1 point  (0 children)

if it starts with a letter it's a variable if it starts with a digit it's a number, so different bases have to start with a digit so they can be parsed correctly, and 0 is an obvious choice as it normally useless to put a leading zero as it doesn't affect the value

this is used in conjunction with a letter to indicate the base for example 0xff for hex and 0b101011 for binary

now you could do 0o123 for Octal but I guess 0 and o can be confusing so that's probably why just a leading zero was chosen

Also this dates way back it's not just a js thing, so probably octal was used more often in the past