This should work
function pushToAry(name, val) {
for (var i = 0; i < ARY.length; i++) {
if (ARY[i].hasOwnProperty(name)) {
ARY[i][name] = val;
return;
}
}
var obj = {};
obj[name] = val;
...
You might want to consider revisiting your data structure. In more than a few instances it will cause you to write more code than you would need if you used a more native structure. (For instance, this function could almost be re-written as function pushToAry(name, val) { ARY[name] = val; } (If course, you would lose the ability to have duplicates - but that is fairly easily solved)