Hey guys, I got an error in javascript and it won't get away. :-)
In the little recursive thingy following, I want to replace a value inside a (nested) object.
var testobj = {
'user': {
'name': 'Mario',
'password': 'itseme'
}
};
updateObject('emesti', 'password', testobj)
function updateObject(_value, _property, _object) {
for(var property in _object) {
if(property == _property) {
_object[property] = _value;
}
else if(objectSize(_object) > 0) {
updateObject(_value, _property, _object[property]);
}
}
return _object
};
function objectSize(_object) {
var size = 0, key;
for (key in _object) {
if (_object.hasOwnProperty(key)) size++;
}
return size;
};
After running this, firefox throws the exception "too much recursion" on the line else if(objectSize(_object) > 0) { .