I am trying to filter an array of objects by its content, i.e.:
https://jsfiddle.net/z7g3unyu/2/
var arr =[
{
"uid": "1",
"name": "John Doe"
},
{
"uid": "2",
"name": "Kate Roe"
}
];
var newArr = arr.filter(function(e) {
return e["uid"] == 1;
});
alert(newArr["name"]);
I wanted to create a new array that contains only one object which uid is equal to 1. However, it gives me undefined. What am I doing wrong?