JSFiddle - React, Tailwind, and code Playground

by rpflorence

JavaScript

if (typeof Object.create !== 'function'){
  Object.create = function (o){
    function F() {}
    F.prototype = o
    return new F
  }
}

var widget = {
    doSomething: function (){
        console.log('something');
    }
};

var myWidget = Object.create(widget);

myWidget.old = myWidget.doSomething;

myWidget.doSomething = function (){
    console.log('something else');
    this.old();
};

myWidget.doSomething();