how to get values from array objects in javascript with examples?
Answers
Answered by
0
Explanation:
You can loop over the array and test for that property:
function search(nameKey, myArray){
for (var i=0; i < myArray.length; i++) {
if (myArray[i].name === nameKey) {
return myArray[i];
}
}
}
var array = [
{ name:"string 1", value:"this", other: "that" },
{ name:"string 2", value:"this", other: "that" }
];
var resultObject = search("string 1"
Similar questions
Geography,
5 months ago
Science,
5 months ago
English,
5 months ago
Math,
11 months ago
Social Sciences,
1 year ago
CBSE BOARD X,
1 year ago
English,
1 year ago