Answers for "js dictionary get key value"

2

get keys of dictionary js

// Get keys of a dictionary
let dict = { a:1 , b:2 , c:3 }

console.log( Object.keys(dict) ) // expected output : ['a', 'b', 'c']
Posted by: Guest on July-20-2020
0

how to get key from value in javascript

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


const map = {"first" : "1", "second" : "2"};
console.log(getKeyByValue(map,"2"));
 Run code snippetHide results
Posted by: Guest on December-01-2021

Code answers related to "js dictionary get key value"

Code answers related to "Javascript"

Browse Popular Code Answers by Language