how can I retrieve specific property of an object of multiple objects [duplicate]

First step is to extract name. You can use map.

elements.map(x=>x.name)

Second step is to join it to one string using join

const result = elements.map(x=>x.name).join(' - ');

Leave a Comment