Answers for "find array object by key value javascript"

4

js find key by value in object

Object.keys(object).find(key => object[key] === value)
Posted by: Guest on December-30-2020
0

javascript object get value by key in array

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", array);
Posted by: Guest on September-15-2021

Code answers related to "find array object by key value javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language