Javascript object variable name as number

Problem

Below, i shows up as “i”, not the number I am iterating through. How do I correct this? Thanks!

for (i = 0; i < 10000; i++) {
var postParams = {
i : 'avalueofsorts'
};
}

Problem courtesy of: user375566

Solution

for (var i = 0, l = 10000; i < l; ++i) {
var postParams = {};
postParams[i] = 'avalueofsorts'
}

Per Cybernate’s comment, you can create the object beforehand and just populate it otherwise you create it each time. You probably want this:

for (var i = 0, l = 10000, postParams = {}; i < l; ++i) {
postParams[i] = 'avalueofsorts'
}

Solution courtesy of: meder omuraliev

View additional discussion.