JSFiddle - React, Tailwind, and code Playground
by Travis Harris
JavaScript
function shootRightHandGun(str){
console.log("Shot " + str + " from right!")
}
function shootLeftHandGun(str){
console.log("Shot " + str + " from left!")
}
var shooter = {fire : function(){shootRightHandGun("shotgun");}}
console.log('original');
shooter.fire();
var temp = shooter.fire;
shooter.fire = (function(t){
return function(){
t();
shootLeftHandGun("handgun");
}
})(temp);
console.log('appended');
shooter.fire();
shooter.fire = function(){shootLeftHandGun("handgun");};
console.log('edited');
shooter.fire();