Computer Science, asked by gangineni1024, 11 months ago

how to get values from array objects in javascript with examples?

Answers

Answered by KokilaAbhishek
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