-
-
Save olivier-spinelli/ef5c0555c3237876b3ff4eb6fecf0ce5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function memorize( f ) { return f; } | |
function MyObject( name ) { | |
this.name = name; | |
} | |
MyObject.prototype.show = function( x, y ) { | |
console.log( this.name, x, y ); | |
} | |
var o1 = new MyObject( 'o1' ); | |
var o2 = new MyObject( 'o2' ); | |
o1.show = memorize( o1.show ); | |
o2.show = memorize( o2.show ); | |
o1.show( 3, 6 ); | |
o2.show( 4, 7 ); | |
o1.show.replay(); | |
o2.show.replay(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment