JavaScript Debugging Interactive interpreter variables

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!


Note that these only work in the developer tools of certain browsers.

$_ gives you the value of whatever expression was evaluated last.

"foo"             // "foo"
$_                // "foo"

$0 refers to the DOM element currently selected in the Inspector. So if <div id="foo"> is highlighted:

$0                      // <div id="foo">
$0.getAttribute('id')   // "foo"

$1 refers to the element previously selected, $2 to the one selected before that, and so forth for $3 and $4.

To get a collection of elements matching a CSS selector, use $$(selector). This is essentially a shortcut for document.querySelectorAll.

var images = $$('img');  // Returns an array or a nodelist of all matching elements

¹ alias to either document.getElementById or document.querySelector

Got any JavaScript Question?