Skip to content

Instantly share code, notes, and snippets.

@andresgallo
Created October 14, 2012 20:52
Show Gist options
  • Save andresgallo/3889790 to your computer and use it in GitHub Desktop.
Save andresgallo/3889790 to your computer and use it in GitHub Desktop.
constructor
function myClass(params){
if(typeof params === 'undefined')params = {};
if( !('someOtherParam' in params)params.someOtherParam = 'blah';//Neat way to set default params in stuff :)
this.params = params; //bind params to this instance
this.set = function(){
//Do your thing
if(typeof this.params.callback === "function")this.params.callback();
}
this.clear = function(){
}
}
var myClassAttributes = {
callback : function(){
},
someOtherParam : 'some'//Just for concept on passing other parameters to a class
}
var firstInstance = new myClass(myClassAttributes);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment