Preview:
function getObjectKeyByValue ( obj value ){
	return Object.keys(obj).find(key => obj[key] === value)
}

const myObject = {
  "key1" : "value 1",
  "key2" : "value 2"
}

const myKey = getObjectKeyByValue ( myObject , "value 2")

console.log ( myKey )
//print key2

downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter