What you're doing is not unreasonable and should work fine. Purely at the level of readability, I might go with
for(var i=1; i<496; i++) {
function get_callback(n) {
return function(term, def) {
myApp.quizlet[0].terms[n] = { term: term, definition: def};
};
}
myApp.getTerm(i, get_callback(i));
};
If you are comfortable using Function.bind:
function callback (n, term, def) {
myApp.quizlet[0].terms[n] = { term: term, definition: def};
}
for(var i=1; i<496; i++) {
myApp.getTerm(i, callback.bind(this,i));
}
We bind the first argument to i, resulting in a "curried" function taking the term and def arguments.
Then of course there is this horrible hack, do not try this at home.
for(var i=1; i<496; i++) {
try { throw i; }
catch (i) {
myApp.getTerm(i, function (term,def) {
myApp.quizlet[0].terms[i] = { term: term, definition: def};
});
}
}