30 lines
505 B
JavaScript
30 lines
505 B
JavaScript
/* JavaScript Object Boilerplate *
|
|
* @version 1.0
|
|
* @author - Gerrit Linnemann
|
|
*/
|
|
|
|
|
|
// Constructor
|
|
function Animal(input) {
|
|
// always initialize all instance properties
|
|
if(typeof input === 'object') {
|
|
this.name = input.name;
|
|
this.age = input.age;
|
|
} else {
|
|
this.name = input;
|
|
this.age = -1; // default value
|
|
}
|
|
}
|
|
|
|
// public methods
|
|
Animal.prototype.fooBar = function() {
|
|
|
|
};
|
|
|
|
// private function
|
|
var myFunction = function() {
|
|
|
|
}
|
|
|
|
// export the class
|
|
module.exports = Animal; |