Skip to content

Instantly share code, notes, and snippets.

@olivier-spinelli
Created November 4, 2016 16:06
Show Gist options
  • Save olivier-spinelli/ef5c0555c3237876b3ff4eb6fecf0ce5 to your computer and use it in GitHub Desktop.
Save olivier-spinelli/ef5c0555c3237876b3ff4eb6fecf0ce5 to your computer and use it in GitHub Desktop.
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