array to string in javascript:
var array = ["power","education"];
var string = array.toString();
Result: power,education
array to string in javascript: enclosed with single quotes(' ')
Using ES6 with string interpolation and arrow function.
You can use join() or toString() to display each item separated by a comma
var array = ["power","education"];
console.log(array.map(x=>`'${x}'`).join(','))
console.log(array.map(x=>`'${x}'`).toString());
Result: ' power','education'
No comments:
Post a Comment