Mega Code Archive

 
Categories / JavaScript DHTML / Language Basics
 

Use for in loop to display all attributes from an object

<html> <head>     <title>For In Loop Example</title> </head> <body> <script type = "text/javascript">     var aObject = new Object;          aObject.name = "A";     aObject.type = "b";     aObject.myValue = "c";          for (var obj in aObject) {         document.write(obj + " = " + aObject[obj]+"<BR>");     } </script>      </body> </html>