Javascript examples for Object:Object Property
Return name of object property by value
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/*from w w w . j av a 2s . c o m*/ var codes = { "admin": 3, "manager": 2, "basic": 1 } var accountType = 2; for (i in codes) { if (codes[i] == accountType) { console.log(i); } } } </script> </head> <body> </body> </html>