= function(){...}; var my_new_object = new MyNewClass; my_new_object.do(); my_new_object.undo(); Finally, you can also emulate horizontal reuse, or runtime "modification" and "addition" of class/object behavior with reflection . share | improve this answer answered Feb 16 at 3:48 dukeofgaming 7,258 1 13 39 feedback up vote 2 down vote You have encountered