Javascript examples for Object:Object Operation
Find duplicate value in JavaScript object
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/*from w w w . ja v a 2s.com*/ var answers = {'a': 3,'b': 2,'c': 3, 'd': 1}; var keys = Object.keys(answers); var dupe = false; for(var i=0;i<keys.length;i++){ for(var j=i+1;j<keys.length;j++){ if(answers[keys[i]] === answers[keys[j]]){ dupe = true; break; } } if(dupe){ console.log("dupe value is there.."); break; } } } </script> </head> <body> </body> </html>