Created
July 22, 2011 08:09
-
-
Save magiconair/1099065 to your computer and use it in GitHub Desktop.
Base class definition
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
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