I have an array of objects in TypeScript(Angular), and I want only names from this array if details array is not empty
[
{name: "Joe", detail: []},
{name: "Kevin", detail: [{salary: 2400}] },
{name: "Peter", detail: [{salary: 2100}]}
]
I want this result Kevin,Peter in one variable
Currently I have done this
[
{name: "Joe", detail: []},
{name: "Kevin", detail: [{salary: 2400}] },
{name: "Peter", detail: [{salary: 2100}]}
].map(function(elem){
return elem.name;}).join(",")
Can anyone help me to do this in Typescript or JavaScript?