For example I have an array like this
{
"employees": [
{ "name": "Ram", "email": "[email protected]", "age": 23 },
{ "name": "Shyam", "email": "[email protected]", "age": 28 },
{ "name": "John", "email": "[email protected]", "age": 33 },
{ "name": "Bob", "email": "[email protected]", "age": 41 }
]
}
If I want an array like {"sam","shyan","john","bob"}
I got it , just using map
arrayname.map((item) => item.name);
BUT if I want an array like this from above array
{
"employees": [
{ "name": "Ram", "email": "[email protected]" },
{ "name": "Shyam", "email": "[email protected]" },
{ "name": "John", "email": "[email protected]" },
{ "name": "Bob", "email": "[email protected]" }
]
}
How can I do that? Thank you a lots