Javascript examples for Object:Object Keys
Iterate over Objects with numeric keys
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from w ww. java 2s . com var myObj = { 5: "foo", 25: "bar" }; var i=0; Object.keys( myObj ).forEach(function ( name, index ) { var value = myObj[name]; console.log(++i); console.log(name); // the property name console.log(value); // the value of that property console.log(index); // the counter }); } </script> </head> <body> </body> </html>