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