javascript:array to string in javascript:enclosed with single quotes



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'




Comments

Popular posts from this blog

Why Mark Zuckerberg’s Choose 4

Error message when I run sudo: unable to resolve host (none)

Convert MBR to GPT