Skip to content

Instantly share code, notes, and snippets.

@corbanb-snippets
Created March 9, 2012 15:11
Show Gist options
  • Save corbanb-snippets/2006911 to your computer and use it in GitHub Desktop.
Save corbanb-snippets/2006911 to your computer and use it in GitHub Desktop.
JS: Class Snippet
/**
@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