Skip to content

Instantly share code, notes, and snippets.

@jamesob
Created September 12, 2011 19:01
Show Gist options
  • Save jamesob/1212074 to your computer and use it in GitHub Desktop.
Save jamesob/1212074 to your computer and use it in GitHub Desktop.
Anonymous functions are beautiful.
/*
* concise, but cryptic for the first two minutes you see this
*/
(function ($) {
$(selector).each(function () {
// code
});
$(selector).each(function () {
// code
});
$(selector).each(function () {
// code
});
})(jQuery);
/*
* clunky pollution of global namespace
*/
var fakeMeaninglessNamespacingFunction = function() {
var $ = jQuery;
$(selector).each(function () {
// code
});
$(selector).each(function () {
// code
});
$(selector).each(function () {
// code
});
}
fakeMeaninglessNamespacingFunction();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment