Consider I have the following variable:
var result = {
"Items": [
{
"location": "New York",
"visible": false,
"destinations": [
4,
3,
5
],
"id": 3,
"coordinates": {
"lng": -74.17,
"lat": 40.68
}
},{
"location": "Madrid",
"visible": false,
"destinations": [
0,
4
],
"id": 0,
"coordinates": {
"lng": -3.56,
"lat": 40.49
}
},
{
"location": "Los Angeles",
"visible": false,
"destinations": [
4,
3,
5
],
"id": 5,
"coordinates": {
"lng": -118.4,
"lat": 33.94
}
}
]
};
If I want to reference to Los Angeles, I would do as below and it works great:
console.log(result.Items[2]);
What if I don't know the order but I know its id (5). How can I reference it by its ID?