Get current call stack with `new Error().stack`
arguments.caller
use to be an acceptable way to find what function is calling the current function. Now, if 'use strict';
has been called for the current closure then an error will be thrown preventing the arguments.caller
call.
Getting the current stack trace is just as easy though with new Error().stack
.
function whoCalledMe() {
console.log(new Error().stack);
//doin' somethin'
}
Tweet