Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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"));
Comment

js find key by value in object

Object.keys(object).find(key => object[key] === value)
Comment

to find keys in an object

obj={
  name:"akash",
  age:23
}


keysval=Object.keys(obj)
console.log(keysval)
Comment

PREVIOUS NEXT
Code Example
Javascript :: truthy and falsy values in javascript 
Javascript :: javascript press tab key 
Javascript :: select parent of elemt 
Javascript :: js how to calculate factorial 
Javascript :: js html input limit to 5 words 
Javascript :: page reload detect in jquery 
Javascript :: javascript get smaller of two numbers 
Javascript :: form-data upload file 
Javascript :: String variable props 
Javascript :: sweetalert question 
Javascript :: vue js app component 
Javascript :: socket.io cdn 
Javascript :: DC League of Super-Pets 
Javascript :: javascript create json object from array 
Javascript :: remove array item with index 
Javascript :: javascript object lookups 
Javascript :: web3 get network name 
Javascript :: react convert excel to json 
Javascript :: remove duplicates in array 
Javascript :: javascript console.log 
Javascript :: kendo jquery grid refresh data 
Javascript :: trailing comma javascript 
Javascript :: collapse in angular 4 
Javascript :: angular chart js 
Javascript :: split string with last character and return array in javascript 
Javascript :: react js error boundary functional component 
Javascript :: how to return the max and min of an array in javascript 
Javascript :: Accessing Object Properties with Variables 
Javascript :: nuxt js route 
Javascript :: react-native restart app 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =