I have following JSON:
[ {
"id":1,
"firstName":"Markus",
"lastName":"Maier",
"email":"[email protected]",
"externalId":"mmaie",
"company":"Intel"
},
{
"id":2,
"firstName":"Birgit",
"lastName":"Bauer",
"email":"[email protected]",
"externalId":"bbaue"
} ]
I want to iterate through both objects and get the value of the "email" key.. what is the simplest way to do that? Thanks!
If you want to end up with an array of just the emails, you may want to look into the .map()
function.
var data = [{
"id": 1,
"firstName": "Markus",
"lastName": "Maier",
"email": "[email protected]",
"externalId": "mmaie",
"company": "Intel"
}, {
"id": 2,
"firstName": "Birgit",
"lastName": "Bauer",
"email": "[email protected]",
"externalId": "bbaue"
}];
var emails = data.map(d => d.email);
console.log(emails);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With