Created
September 29, 2015 21:01
-
-
Save taylor-smith/059ad641f16eb9002f0d to your computer and use it in GitHub Desktop.
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
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