Created
January 29, 2014 05:07
-
-
Save S2/8682163 to your computer and use it in GitHub Desktop.
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
var Test = (function () { | |
function Test(){ | |
this.value = "base"; | |
}; | |
Test.prototype = { | |
method : function(){ | |
console.log(this.value); | |
} | |
}; | |
return Test; | |
})(); | |
// mixin | |
(function () { | |
Test.prototype.___method = Test.prototype.method; | |
Test.prototype.appendMethod = function(){ | |
console.log("append"); | |
}; | |
Test.prototype.method = function(){ | |
this.___method(); | |
console.log("override"); | |
}; | |
})(); | |
var object = new Test(); | |
object.appendMethod(); | |
object.method(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment