Created
September 12, 2011 19:01
-
-
Save jamesob/1212074 to your computer and use it in GitHub Desktop.
Anonymous functions are beautiful.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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