Use for in loop to display all attributes from an object : Objects Object Oriented « Language Basics « JavaScript DHTML
- JavaScript DHTML
- Language Basics
- Objects Object Oriented
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>
Related examples in the same category