Skip to content

Instantly share code, notes, and snippets.

@magiconair
Created July 22, 2011 08:09
Show Gist options
  • Save magiconair/1099065 to your computer and use it in GitHub Desktop.
Save magiconair/1099065 to your computer and use it in GitHub Desktop.
Base class definition
define(function() {
// class variable
var id = 0;
// class method
function nextId() {
return ++id;
}
// constructor
function Person(name) {
var self = this;
// private members
var color = 'everything';
// private methods
function likes() {
return self.name + ' likes ' + color;
}
// public members
self.id = nextId();
self.name = name;
// public methods
self.setColor = function(c) {
color = c;
};
self.print = function() {
console.log(likes());
};
}
return Person;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment