I implemented a small (and probably not standard) function to get the call stack in JavaScript. However, this piece of code below only gets the function references. Is it possible the object to every caller?
function getCallStack() {
let stack = [];
let caller = arguments.callee.caller;
while (caller !== null) {
stack.push(caller); // I would like "stack.push([caller, getObject(caller)]);
caller = caller.caller;
}
return stack;
}
If I execute the following piece of code console.log(getCallStack())
, I can get something like [ [Function: f3], [Function: f2], [Function: f1] ]
. I would like to get something like [ [[Function: f3], obj3], [[Function: f2], obj2], [[Function: f1], obj1] ]
where obj1, obj2, obj3
are JUST references to the objects.