Understanding implicit conversion in Javascript
I was looking for a pesky JavaScript error when I was passing one argument, but when it was received, it was completely different. I fixed this, but would like to know what happens in the future.
What I had to pass as an argument is "0616" (with quotes). What I actually passed was 0616 (no quotes).
So when it was received some implicit numeric conversion happened and it was received as 398. I understand the implicit and explicit conversion, but WHAT was going on to turn 0616 into 398. At the beginning of zero there seems to be something to do this is because the other values I passed were nonzero in the most significant digit, preserved just fine. Is it just the ones that start from scratch?
But what is the relationship between 398 and '0616'?
Any ideas?
source to share
0616
is the format of the old octal number. This should be the case in the new specification 0o616
, but the old format is still supported by browsers.
See wiki page :
the 0o prefix was introduced for .... and it must be supported by ECMAScript 6 (the 0 prefix was discouraged in ECMAScript 3 and dropped in ECMAScript 5).
source to share