You need to use recursion:
do = function(i, data, callback){
// if the end is reached, call the callback
if(data.length === i+1)
return callback()
obj = data[i]
// DO SOMETHING
i++;
// call do with the next object
do(i, data, callback)
}
do(0, [a, b, c], function(){
THEN OUTPUT SOMETHING
});
So the same callback (OUTPUT SOMETHING) will be passed on do
and when the end is reached, the callback will be executed.