How to Find out the Caller Function in JavaScript
To find out the caller function, name a non-standard the function.caller property in JavaScript. The Function object is replaced by the name of the function of which you need to find out the parent function name.
If the function Welcome was invoked by the top-level code, the value of Welcome.caller is null, otherwise, it is the function that called Welcome.
There is another method which is no longer supported in modern JavaScript:
The function.caller property replaces the above obsolete arguments.caller property of the arguments object. The arguments.caller property is obsolete, which used to provide the function that called the currently executing function.
The function.caller Property
The function.caller property returns the function that called the specified function. It will return null for strict, generator function callers and async function.