Cheap Computer Parts - Debt Consolidation - Find jobs - Number Ones - Debt Consolidation

PDA

View Full Version : Convert Number to String


asuni449
Feb 24th 2009, 9:21 pm
Hi all,
How to convert Number to String in Javascript.
Thanks.
:confused:

astupidname
Feb 25th 2009, 5:13 am
<script type="text/javascript">

var num = 3;
alert(typeof num);
num = 3 + ''; //simplest to just add a blank string on to the number
alert(typeof num);

</script>

mytor
Feb 25th 2009, 6:15 am
string = number.toString();

igor398
Mar 22nd 2009, 4:06 pm
Why do you want to convert?
js engine does it automatically

robertstr
Mar 25th 2009, 8:25 pm
Hi!

For converting numbers to binary, octal, or hexadecimal strings (or to any other base) you can use, in JavaScript 1.1, the standard method Number.toString(radix) for converting a number to a string representing that number in a non-decimal number system (e.g. to a string of binary, octal or hexadecimal digits)
Wish you succees.