I have the codes below:
<script type="javascript">
var item = 001002004;
alert(item);
</script>
Whenever I see this page in view source in my web browser, I see these lines of code exactly as same as here. But when alert() function runs, I see an unknown message. It alrest ‘6295553’. I don’t know where is this unknown value from. I’m sure anything don’t happen to item and it did not change before of alert.
What do you think ? What’s the problem ?
Any number prefixed with 0 will be considered as octal. and 0x for hexa decimal
I am guessing that you are having it as an numeric value like below or using parseInt function to parse the string and when you alert it you see a different value..
Or probably you are doing something like below
See more details on parseInt @MDN
DEMO HERE