var a = 5;
document.write(a.toString(2));
This will output:
101
You can give toString() a parameter which is the radix in which to output the number.
Of course you can use 8 to get octal version or 16 to get the hexa version of the number.
Very powerful and also very simple
No comments:
Post a Comment