Created
March 9, 2012 15:11
-
-
Save corbanb-snippets/2006911 to your computer and use it in GitHub Desktop.
JS: Class Snippet
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
/** | |
@namespace PX4.Class | |
@author | |
@date | |
@description | |
@requires | |
*/ | |
var PX4 = PX4 || {}; | |
PX4.Class = (function(){ | |
function Class(){ | |
if ( !(this instanceof Class) ) { return new PX4.Class(); } | |
var self = this; | |
var _name = null; | |
var privateFunction = function(){ | |
//do some private functionality | |
} | |
//public method | |
self.doSomething = function (){ | |
privateFunction(); | |
} | |
//Example public setter function | |
self.setName = function (value){ | |
_name = value; | |
} | |
//Example public getter function | |
self.getName = function(){ | |
return _name; | |
} | |
} | |
return Class; | |
})(); //self calling. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment