user1460043
user1460043

Reputation: 2481

Access second/third/... last result in Chrome developer tools / Firebug JavaScript console

In Chrome developer tools' JavaScript console as well as in Firebug's we can access the result of the last evaluated expression via $_.

Is there a way to access the second/third/... last result? I am interested in answers for both Chrome DevTools and Firebug.

Upvotes: 5

Views: 2251

Answers (2)

antoHuman
antoHuman

Reputation: 349

This is an old question, so I do not know if this was an option, but now with Chrome and Firefox (for any object) you can do something similar to this.

  1. Use the mouse to right click on the object.
  2. A menu will open and you can choose "Store as global variable" to store it as a variable.

Be mindful that clicking on the space outside the object representation, even on the same line, will open a different menu.

Upvotes: 4

Sebastian Zartner
Sebastian Zartner

Reputation: 20105

The simple and unfortunate answer is no, there is no way to access the value of the second/third/... last evaluated expression.
See Chrome's Command Line API documentation as well as Firebug's documentation.

Only the inspected elements have a history like that. That means, you can access the second-last inspected element via $1, the third-last one via $2 and so on.

Upvotes: 5

Related Questions