Skip to content

Instantly share code, notes, and snippets.

@cmalven
Last active October 13, 2015 07:07
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmalven/4157659 to your computer and use it in GitHub Desktop.
Save cmalven/4157659 to your computer and use it in GitHub Desktop.
Basic Javascript Object
function MyObject(options) {
/*****************************************
/* PRIVATE VARS
/****************************************/
var self = {
}
/*****************************************
/* PUBLIC VARS
/****************************************/
self.defaults = {
}
/*****************************************
/* PRIVATE METHODS
/****************************************/
var init = function() {
updateSettings();
addEventListeners();
}
var updateSettings = function() {
if (typeof options == 'object') {
self.settings = $.extend(self.defaults, options);
} else {
self.settings = self.defaults;
}
}
var addEventListeners = function() {
}
/*****************************************
/* PUBLIC METHODS
/****************************************/
self.myFunction = function() {
}
// Initiate
init();
// Return the Object
return self;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment