Google's Chrome browser has a nice feature which shows you the return value in the debugger before you step out of the function. It shows up in the Scope
list in one of the debugger panes along with Watch
, Call Stack
, etc. It looks like this.
I'm curious if there's console access to this variable?
I frequently have a need to do something like this while debugging:
<return>.filter(function(z) { return z >= 0; })
Or any other arbitrary way to understand whether the return value was what I was expecting. Unfortunately, I can't find a way to refer to <return>
in the console. I was hoping there was some variable like $_
that would give me access, but I haven't found look looking in the likely places.
I realize I can look at the <return>
object as it appears in the Scope
list but if the item is a large array or complex object, etc., I would prefer to type some code into the debugger while paused at a breakpoint to see if I'm getting what I expect.
What I typically resort to is modifying my code to save the return value to a variable, and then reproducing the steps to get back to the breakpoint, but this is annoying.
Thoughts?
console.log()
the output in some way, you can right click the output in the console and store it as a global variable, from there you can access the data and manipulate as necessary of course this is a temporary value, so it will disappear when you leave the current page session – iam-decoder Oct 13 '15 at 17:08Store as Global Variable
menu item isn't available when clicking on the return value,<return>
in theScope
list. So, unfortunately it doesn't work like a variable that was output fromconsole.log()
. – Kevin Bullaughey Oct 13 '15 at 20:04return new SomeClass();
and I want to see what the instance that will be returned looks like while paused in the debugger, there's no way for me to do this without either poking through the<return>
object in theScope
menu or by modifying my code to save the object before returning and then re-running the code to get back there and look at it. – Kevin Bullaughey Oct 13 '15 at 20:07