Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Possible to tell if two objects are the same in Chrome debugger?

In Eclipse, the debugger shows a unique session id next to each object (for Java and AS3, anyway). This makes it simple to identify the same object appearing in multiple contexts.

I'm working on a JavaScript project, and would like the same ability to identify objects in the Chrome debugger (e.g. in the "Scope Variables" pane). Is this information tracked by the browser/debugger? Is there a different way to identify an object across contexts, without adding code (a purely IDE way of doing this, applicable to any context).

like image 874
ericsoco Avatar asked Jul 16 '13 18:07

ericsoco


People also ask

How do I run debugger in Chrome?

The Chrome Web Inspector and Debugger are conveniently built-in with Chrome. You can launch it by hitting F12 while in your browser or by right clicking on a web page and selecting the Inspect menu item.


3 Answers

Technically this is possible. You probably already can see it, if you use Chrome Dev Tools for Java (Eclipse-based debugger). http://code.google.com/p/chromedevtools

As to in-browser debugger, UI merely lacks UI for this. I guess you should file a feature request on this at: http://crbug.com

P.S. Note, that this not an address at all – both Java and JavaScript move their objects in memory at random moments.

like image 86
beefeather Avatar answered Oct 22 '22 18:10

beefeather


I believe this is possible using Chrome Dev Tools by:

  1. Taking a Heap Snapshot and opening up console while in summary view
  2. Printing the object in the console
  3. Right clicking the console output and selecting "Reveal in Summary View" (If you don't see this option it is likely that you do not have the profile panel open)
like image 23
LucasZW Avatar answered Oct 22 '22 18:10

LucasZW


JavaScript does not have memory addresses. "The same variable" can be compared using the triple equal sign notation (anObjectReference === anotherObjectReference)

like image 32
Brian Avatar answered Oct 22 '22 17:10

Brian