Answers for "find key index in object javascript"

7

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

indexOf by object key

var index = peoples.findIndex(p => p.attr1 == "john")
Posted by: Guest on July-05-2020
0

js find index of object by value of property and return it's key

const index = Data.findIndex(item => item.name === 'John');
Posted by: Guest on April-23-2021

Code answers related to "find key index in object javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language