Test JavaScript
Object.prototype.clone = function(){ var f = function(){}; f.prototype = this; var obj = new f(); return obj; } var parent = new Object(); parent.id = "parent" parent.greeting = function(){ println(this.id + " : Hello"); }; parent.greeting(); var child = parent.clone(); child.id = "child" child.greeting(); // inherited child.greeting = function(){ println(this.id + " : Bye!"); }; child.greeting(); // overridden var grandchild = child.clone(); grandchild.id = "grandchild" grandchild.greeting(); // inherited grandchild.greeting = function(){ println(this.id + " : Good morming!"); }; grandchild.greeting(); // overridden