Return to Snippet

Revision: 17191
at August 26, 2009 10:09 by elugardo

Initial Code
// output the name and value of all the objects properties
var s = "";

for (var property in myObject)
s = s + "\n "+property +": " + myObject[property] ;


Initial URL

Initial Description
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

Initial Title
Output the name and value of the properties in a javascript object

Initial Tags
javascript, object, json

Initial Language