Created
October 14, 2012 20:52
-
-
Save andresgallo/3889790 to your computer and use it in GitHub Desktop.
constructor
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
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