I was looking through new stuff added to jQuery 1.7 and I saw they now have jQuery.Callbacks() http://api.jquery.com/jQuery.Callbacks/.
The documentation shows you how
To expand on @Rockets answer a bit and clear up some confusion:
The reason that one might need to use jQuery's $.Callbacks
is multifaceted:
They take that information and send it through the jQuery callback function which then allows them to have split their code into better manageable pieces with which to work with.
So (for example) if you look at @Rocket's code:
var clickCallbacks = $.Callbacks();
clickCallbacks.add(function() { //one one function piece
//parse and do something on the scope of `this`
var c = parseInt(this.text(), 10);
this.text(c + 1);
});
clickCallbacks.add(function(id) { //add a second non-related function piece
//do something with the arguments that were passed
$('span', '#last').text(id);
});
$('.click').click(function() {
var $ele = $(this).next('div').find('[id^="clickCount"]');
clickCallbacks.fireWith($ele, [this.id]); //do two separate but related things.
});