JSFiddle - React, Tailwind, and code Playground

by whitewolf

JavaScript

function aopTest(obj, func) {
    var old = obj[func];
    obj[func] = function() {
        console.log("before....");
        old();
        console.log("after....");
    }
}

var obj = {
    "test": function() {
        console.log("body......");
    }
};

aopTest(obj, "test");

obj.test();