javascript - parseInt outputting int instead of octal number -
i've been following course in treehouse javascript. i'm on parseint method. in 1 of example, code shown:
var j = parseint("012");
saving , running in chrome's console resulted 10 in example (which understandable 012 10 in octal), in own browser, resulted 12. correct or doing wrong?
it's not strange - behavior implementation dependent.
it parse octal 012 or decimal 12.
it's best specify radix parameter when using parseint()
, example parseint('012', 10)
.
Comments
Post a Comment