Skip to content

Instantly share code, notes, and snippets.

@erzr
Created December 11, 2012 00:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erzr/4254777 to your computer and use it in GitHub Desktop.
Save erzr/4254777 to your computer and use it in GitHub Desktop.
Javascript Prototype Pattern with Default Options
var Slideshow = (function($) {
function Slideshow(options) {
var defaults = {
timeout: 0.5,
selector: '.content'
};
this.options = $.extend(defaults, options);
};
Slideshow.prototype.alertSelector = function() {
console.log(this.options.timeout);
};
return Slideshow;
})(jQuery);
var slideshow = new Slideshow({
timeout: 0.9
});
slideshow.alertSelector();​
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment