I have a output like this
Output :
[{service: 'xdc'},{service: 'cddc'}, {service: 'cdcd'},{service: 'cddc'}]
I need to convert like this
output : [xdc,cddc,cdcd,cddc]
Advertisement
Answer
You can use Array.prototype.map() combined with Destructuring assignment
Code:
const output = [{service: 'xdc'},{service: 'cddc'}, {service: 'cdcd'},{service: 'cddc'}] const result = output.map(({ service }) => service) console.log(result)