Iterate over all unique pairs of entries in an object - Javascript Object

Javascript examples for Object:Reflection

Description

Iterate over all unique pairs of entries in an object

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=( function() {/*from  ww w. j  ava  2  s  .  c om*/
var obj = {a:"A", b:"B", c:"C"};
function foo(a, b) {
   console.log(a,b);
}
for(i in obj) {
    var a = obj[i];
    delete obj[i];
    for(j in obj) {
        foo(a, obj[j]);
    }
}
    });

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials