Basic JavaScript Question:

How to convert numbers to strings using JavaScript?

Tweet Share WhatsApp

Answer:

We can prepend the number with an empty string in JavaScript

var mystring = ""+myinteger;

//or

var mystring = myinteger.toString();
We can specify a base for the conversion,
var myinteger = 14;
var mystring = myinteger.toString(16);

mystring will be "e".

Download JavaScript PDF Read All 114 JavaScript Questions
Previous QuestionNext Question
How to convert a string to a number using JavaScript? How to test for bad numbers using JavaScript?