You can simply use the console.trace() method of the console object which gives the trace on the console. It will show the call path taken to reach the point at which you call console.trace().
The stack Property
You can create an Error object and return stack attribute:
Error objects are thrown when runtime errors appear. It can also be used as a base object for user-defined exceptions. The stack is a non-standard property of Error objects that offers a trace of which functions were invoked, in what order, from which line and file, and with what arguments. Stack string proceeds from the latest calls to the earlier ones, leading back to the original global scope call.