If I use console.log
to log an object from inside a script, I can see that object in the console, and I can inspect it by clicking the little arrows. So I can see what methods it has (even in its prototype). But is it possible for me to run one of those methods from right there in the console?
In other words, is there some kind of magic variable (similar to $0
) that I can type into the console, which will get me the last logged object?
You can actually use $_
to get the previously evaluated statement
$$ // Returns an array of elements that match the given CSS selector.
$0 // The currently-selected object in the inspector.
$_ // The previously evaluated statement
$1 // The previously-selected object in the inspector.
$n(index) // Access to an array of last 5 inspected elements.
For a complete list of everything there is that you can use for all parts of chrome check out the cheatsheet. http://anti-code.com/devtools-cheatsheet/
There is no such magic variable for objects logged via console.log at the moment. Please file a feature request if you need one: http://webkit.org/new-inspector-bug
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With