convert to string js code example
Example 1: turn object into string javascript
var obj = {a: "a", b: "b" };
var string = JSON.stringify(obj);
Example 2: javascript convert number to string
var myNumber=120;
var myString = myNumber.toString();
Example 3: javascript to string
num.toString();
Example 4: change no to string in js
var num = 15;
var n = num.toString();
Example 5: jquery cast to string
value.toString()
String(value)
value + ""
Example 6: 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))
}
false
true
Wed Dec 30 2020 20:35:17 GMT-0500 (Eastern Standard Time)
12345
12345