Why does each iteration of this:
var o = {};
var foo = [['a',1],['b',2],['c',3],['d',4],['e',5]];
for(var i = 0; i < 5; i++)
{
o.__defineGetter__(foo[i][0], function() {
return foo[i][1];
});
console.info(JSON.stringify(o));
}
Reset all previous assignments and output this:
{"a":1}
{"a":2,"b":2}
{"a":3,"b":3,"c":3}
{"a":4,"b":4,"c":4,"d":4}
{"a":5,"b":5,"c":5,"d":5,"e":5}
When what I expect / want to finish with is:
{"a":"1","b":"2","c":"3","d":"4","e":"5"}
How do I achieve what I want?