JavaScript get caller function

Sometimes we need to know the function that called other function in JavaScript.

We can use arguments for that like this:

function WhoIsMyCaller()
{
   console.log("caller = " + arguments.callee.caller.toString());
   // do something
}

tags: & category: -