Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to inspect JavaScript function return value in Chrome debugger?

Coming from gdb, it would print the return value of a function when it finished. Is there a way to get this information from the Chrome debugger without changing the source being debugged?

like image 541
John Freeman Avatar asked Mar 12 '12 06:03

John Freeman


People also ask

How do I inspect a JavaScript variable in Chrome?

To view any variable in chrome, go to "Sources", and then "Watch" and add it. If you add the "window" variable here then you can expand it and explore.

How do I debug JavaScript events in Chrome?

Open Google Chrome and press F12 to open Dev Tools. Go to Event Listener Breakpoints, on the right: Click on the events and interact with the target element. If the event will fire, then you will get a breakpoint in the debugger.

How do I debug inspect element in Chrome?

Right-click an element and select the Inspect Element from the context menu. That will open Chrome DevTools and highlight the element that you clicked on. Click the Inspect Element button ( Ctrl + Shift + C ) on the top left corner of Chrome DevTools and hover over the control.


1 Answers

A fix for this was implemented as of Nov 5, 2013, but apparently is only released, while I'm writing this, in Chrome Canary. (I see it in 33.0.1719.0, but don't see it in the Chrome Beta version 32.0.1700.19 beta.)

If the version you're running does have it, then when you step through a return statement, the debugger's Scope Variables Local scope includes a <return> entry with the value.

(I need to use Canary for the main debugging I do, but didn't notice the presence of the <return> entry until seeing the referenced notice in the issue!)

like image 192
klm Avatar answered Sep 29 '22 03:09

klm