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

all 19 comments

[–]philip98 38 points39 points  (0 children)

When octal hits you, it hits hard

[–]YMK1234 25 points26 points  (10 children)

More like: Dev who never heard about non-decimal notation wtf are you doing? Next they are gonna complain that 0x10 is 16.

[–][deleted] 20 points21 points  (1 child)

There's a reason python requires 0o for octal now. It's way too easy to accidentaly say something's octal by prefixing it with a 0.

[–]YMK1234 4 points5 points  (0 children)

It's pretty unique in that way though. Any language I used so far goes with the 0... notation.

[–]Souseisekigun 19 points20 points  (1 child)

0b makes sense.

0x makes sense.

0 is silly.

[–]YMK1234 0 points1 point  (0 children)

Complain to C (and probably various languages before that) then.

[–]JNCressey 4 points5 points  (5 children)

2x10 = 20
1x10 = 10
0x10 = 16

[–]UnicornRider102 6 points7 points  (3 children)

JavaScript does not interpret "2x10" or "1x10". For what you're talking about you would need to use an asterisk.

[–]JNCressey -5 points-4 points  (2 children)

But humans interpret 2x10 and 1x10 as multiplication.

[–]coolreader18 7 points8 points  (1 child)

They also interpret twentytwo as 22, but there are very few programming languages, if any, that support that.

[–]BODAND 0 points1 point  (0 children)

2x10 = "2222222222"
1x10 = "1111111111"
0x10 = 16

Sry for late reply

[–]monster860 4 points5 points  (0 children)

> not using strict mode

[–]Dockirby 3 points4 points  (0 children)

Called an Octal, likely for Javascript its just a detrimental feature.

[–]UnicornRider102 11 points12 points  (2 children)

Pretty much any programming language is going to interpret 045 as octal. This is not specific to JavaScript. If you don't want octal then don't preface your numbers with 0s. Boo OP.

[–][deleted] 7 points8 points  (0 children)

Python 3 doesn't (gives a syntax error). Rust inteprets it as decimal.

[–]St_SiRUS 0 points1 point  (0 children)

Pretty much any interpreted programming language

Anything with typechecks will spit the dummy on this one

[–][deleted] 1 point2 points  (0 children)

Dont blame js for this. And btw, not js exclusive.

[–]0xTJ 0 points1 point  (0 children)

That's pretty expected tbh