JS toString Function


toString() function converts a number to the specified string format, such as 2 based.

var nm=2;
nm.toString(2); //10
nm.toString(); //2
nm.toString(10); //2
nm.toString(8); //2


var nm = 24;
nm.toString(2); //11000
nm.toString(); //24
nm.toString(10); //24
nm.toString(8); //30
nm.toString(16); //18


toString() method can convert all elements of an array into strings. It returns a comma separated list of the strings.

var arr = ["be", 32, "color", 9, "u", 2, 3.2, "i","we"];
var ret = arr.toString();
alert(ret); //be,32,color,9,u,2,3.2,i,we
convert.idontcarewhatyouthink.net © 2021  Terms of Use | Home