4

What does mean == $0 in the code inspector?
See this screenshot:

enter image description here

There is no bug with my code execution.
But as the inspector tries to tell me something that I don't understand, I think It is a great idea to find out about this «possibly important message».

I noticed it a couple times in the Chrome inspector on many tags.
Sometimes on inputs, sometimes on the body tag !! (Scary!)

This message may show also in FireBug and other inspectors... I don't know.
And I confess : I didn't check. :D

I just don't know what to search about it on the web.
What can one search about with this only clue : == $0 ??

Louys Patrice Bessette
  • 33,375
  • 6
  • 36
  • 64
  • 1
    [This](https://willd.me/posts/0-in-chrome-dev-tools) may be of assistance. – Joachim Isaksson May 21 '16 at 23:15
  • 1
    Dev Tools remembers the last five DOM elements (or JavaScript heap objects) that you've selected in the tab (or Profiles panel). It makes those objects available as $0, $1, $2, $3, and $4. $0 returns the most recently selected element or JavaScript object, $1 returns the second most recently selected one, and so on. Source [developer.chrome.com](https://developer.chrome.com/devtools/docs/commandline-api#0-4) – u238 May 21 '16 at 23:15
  • @u238: Haaa... So this only is my "selection" of the item to inspect that triggers this scary thing ??? lolll Post it as an answer my friend! You merit some reputation points for this fast answer! – Louys Patrice Bessette May 21 '16 at 23:26
  • Exactly Louys. This "possibly important message" shows just selection :) I just did copy and paste, therefore no need points. – u238 May 21 '16 at 23:40
  • 1
    @u238 Okay then. But... By the way, Joachim Isaksson's link is more precise than your (maybe instructive but hadbanging) «developer.chrome.com» link for this specific. Thank you both! My stress level is going down (lol). – Louys Patrice Bessette May 21 '16 at 23:46
  • Possible duplicate of [What does ==$0 (double equals dollar zero) mean in Chrome Developer Tools](http://stackoverflow.com/questions/36999739/what-does-0-double-equals-dollar-zero-mean-in-chrome-developer-tools) – Quentin Jul 06 '16 at 12:40

1 Answers1

3

It is a hint to remind you that the selected DOM element is automatically bound to the variable $0. You can reference it in any console evaluations, or just see what it is by evaluating $0 by itself.

See detailled explanation here.

Nathan Davis
  • 5,636
  • 27
  • 39
Brian Burg
  • 795
  • 4
  • 10
  • You would do others a service to simply mark my answer as accepted so others know that they can look at the question and find an answer. Otherwise it shows up as "unanswered". – Brian Burg May 28 '16 at 14:53