One can iterate over all properties of an object: |
for ( variable in object ) { É } |
function dump_props(obj, obj_name) { |
var result = ""; |
for ( var i in obj ) {
|
} |
return result + "<HR>"; |
} |
Here i is an index and obj[i] is the actual property |
Note user supplies obj and obj_name: |
function car(make, model) { // An Example |
this.make = make; this.model = model; |
} |
mycar = new car("Ford", "Explorer"); |
document.writeln(dump_props(mycar, "mycar")); |