Is there a way to automatically know who called a specific function in JS?
Let's say I have this code:
function1() {
function2();
}
function2() {
console.log('the function who called me is ...' + <magic code here>);
}
When function1
calls function2
, is there any magic way for function2
to know that function1
called it, without passing any additional parameters?