How to Convert a Comma-Separated String into Array

Simple Array

let simpleArray = ["Banana", "Orange", "Apple", "Mango"]
let commaSeperated = simpleArray.join(",");
console.log(commaSeperated);

Result
// 1,2,3,4

Array of Objects with a particular attributes as comma separated.

let arrayOfObjects = [
{
id : 1,
name : "Name A",
address : "Address A"
},
{
id : 2,
name : "Name B",
address : "Address B"
},
{
id : 3,
name : "Name C",
address : "Address C"
}]
let names = arrayOfObjects.map(x => x.name).join(", ");
console.log(names);

Result
// Name 1, Name 2, Name 3
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments