Moin.
Aha. Und wie sieht die Implementierung von iterOwn aus, damit das so funktioniert?
Es lässt sich schon irgendwie drehen, dass das so oder so ähnlich funktioniert. Mal ein Beispiel:
function iterator(obj) {
var i = 0;
var props = [];
for(var prop in obj) {
if(obj.hasOwnProperty(prop))
props.push(prop);
}
return {
next : function() {
if(i < props.length) {
this.key = props[i];
this.value = obj[props[i]];
++i;
return true;
}
else return false;
}
};
}
with(iterator(obj)) while(next()) {
document.writeln(key + ' : ' + value);
}
Das das natürlich totaler Käse ist und wesentlich weniger performant als
for(var prop in obj) {
if(obj.hasOwnProperty(prop))
document.writeln(prop + ' : ' + obj[prop]);
}
ist, ist klar ;)
Christoph