/ Published in: JavaScript
The code below will loop through the properties in an object and alert a string. myObject is in JSON notation. The "for ( x in y)" construct does not work if the Prototype.js library is included on the page
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// output the name and value of all the objects properties var s = ""; for (var property in myObject) { s = s + "\n "+property +": " + myObject[property] ; } alert(s);