Functional Inheritance

// Functional Inheritance
function Parenizor(value) {
    this.setValue(value);}

Parenizor.method('setValue', function (value) {
    this.value = value;    return this;});
Parenizor.method('getValue', function () {
    return this.value;});
Parenizor.method('toString', function () {
    return '(' + this.getValue() + ')';});
myParenizor = new Parenizor(0);myString = myParenizor.toString();

No comments:

Post a Comment