When used with numbers, the toString() method converts a number into a string representation using the base numbering system specified by the optional radix.
For instance the number 8 and toString(2) would return "1000".
Is there a method to achieve the opposite? I.e., convert the string "1000" back into the number 8?
parseInt()
takes a radix as its second argument, so you can do parseInt("1000", 2)
to get what you want.
You can use parseInt using a raidx 2. i.e
parseInt("1000", 2) will return 8
Check the parseInt() Javascript function: http://www.w3schools.com/jsref/jsref_parseInt.asp
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