While executing some random expressions in console, I just found that
010 + ""
returning 8
(even 011,0100.. are returning results by considering octal number system)
What would I have to do if I want to convert a number 010
to a string "010"
? Not only for 010
but for every similar numbers. I managed to find a kind of similar explanation for this here. But that is not explaining how to convert it into a exact string version.
In Javascript 010
is octal literal and converts to 8 in decimal literal. In fact, you should avoid it, as strict mode disallows to use it.
There is no way to distinguish between octal and decimal notation other than parsing function body string :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With