Skip to content

Instantly share code, notes, and snippets.

@taylor-smith
Created September 29, 2015 21:01
Show Gist options
  • Save taylor-smith/059ad641f16eb9002f0d to your computer and use it in GitHub Desktop.
Save taylor-smith/059ad641f16eb9002f0d to your computer and use it in GitHub Desktop.
var myLib = (function() {
// Using IIFE + Closure
var $cachedLookup = $('.element');
function hideCachedElement() {
$cachedLookup.hide();
}
return {
hide: hideCachedElement
}
})();
myLib.hide();
//////
/// Using constructor/prototype pattern
function ExampleLib() {
this.$cachedLookup = $('.element');
}
ExampleLib.prototype.hide = function() {
this.$cachedLookup.hide();
}
var example = new ExampleLib();
example.hide();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment