I'd personally use $.map so the function callback creates a new execution context for each iteration.
As you've tagged the question with jQuery, your code can be as simple as
$($.map(data, function(v, i) {
return $('').html(data[i].name).click(function() {
console.log(data[i]);
});
})).appendTo('body'); //appending for demonstration purposes
Fiddle
Of course, you have to wrap it inside a function and pass the data
array of objects as you were doing previously.