Answers for "how to get specific key in object javascript"

15

how to find the key of an value in an object

function getKeyByValue(object, value) {
  return Object.keys(object).find(key => object[key] === value);
}


const map = {"first" : "1", "second" : "2"};
console.log(getKeyByValue(map,"2"));
Posted by: Guest on August-07-2020
0

how to get particular key value from array of objects in javascrip

var array = [
    { name:"string 1", value:"this", other: "that" },
    { name:"string 2", value:"this", other: "that" }
];

var foundValue = array.filter(obj=>obj.name==='string 1');

console.log(foundValue);
Posted by: Guest on January-26-2022

Code answers related to "how to get specific key in object javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language