Javascript examples for Object:Object Keys
Checking whether key and value exist in Javascript object
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from ww w.j a va 2s .c o m function my(value, object) { return Object.keys(object).map(function (key) { return object[key]; }).some(function (_value) { return _value === value; }) } console.log(my('bar', {foo: 'bar'})) // true console.log(my('baz', {foo: 'bar'})) // false } </script> </head> <body> </body> </html>