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

旧城冷巷雨未停 提交于 2019-12-08 17:47:14

问题


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).


回答1:


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.




回答2:


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)



回答3:


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



来源:https://stackoverflow.com/questions/17684715/possible-to-tell-if-two-objects-are-the-same-in-chrome-debugger

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!