convert integer to string in js code example

Example 1: javascript convert number to string

var myNumber=120;
var myString = myNumber.toString(); //converts number to string "120"

Example 2: javascript convert a number in string

const num = 123; //> type number 123
const str = num.toString(); //> type string "123"

Example 3: how to convert a number to a string in javascript

var number = 1212
var numberString = number.toString();//converts my number that is '1212' to a string

Example 4: how to convert to string javascript

function myFunction() {
  var x1 = Boolean(0);
  var x2 = Boolean(1);
  var x3 = new Date();
  var x4 = "12345";
  var x5 = 12345;

  
  console.log(String(x1))
  console.log(String(x2))
  console.log(String(x3))
  console.log(String(x4))
  console.log(String(x5))

}

//outputs the following: 

false
true
Wed Dec 30 2020 20:35:17 GMT-0500 (Eastern Standard Time)
12345
12345

Example 5: javascript integer to string

var num = 15;
var n = num.toString();