Home > Mobile >  Json object to Apostrophe array
Json object to Apostrophe array

Time:10-20

I have json object like this

[ { "tag": "search" }, { "tag": "test" }, { "tag": "css" }, ]

But i want to get this object like this

'search',
'test',
'css',
'apple',

CodePudding user response:

You can map over the array and extract the tag property value:

const obj = [ { "tag": "search" }, { "tag": "test" }, { "tag": "css" }, ]

const res = obj.map(e=>e.tag)

console.log(res)
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

  • Related