# JS Tip of the Day: Console $ Utilities

**URL:** <https://forum.kirupa.com/t/js-tip-of-the-day-console-utilities/643078>\
**Category:** web dev\
**Created:** [May 19, 2020, 2:27pm UTC](https://forum.kirupa.com/t/js-tip-of-the-day-console-utilities/643078 "2020-05-19T14:27:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)\
**Post date:** [May 19, 2020, 2:27pm UTC](https://forum.kirupa.com/t/js-tip-of-the-day-console-utilities/643078/1 "2020-05-19T14:27:17Z")

</div>

**Console $ Utilities**  
Level: Intermediate

When working within the JavaScript console of your browser, a certain set of debugging APIs are made available to you that don’t exist anywhere else. Of those include a set of helper functions and variables using the `$` character. They consist of:

- `$()`: A shortcut for what is effectively equivalent to `document.querySelector()`
- `$$()`: A shortcut for what is effectively equivalent to `document.querySelectorAll()`
- `$x()`: A shortcut for running an XPath query on the DOM (similar to `document.evaluate()`)
- `$0`: A reference to the selected element within the elements panel (which would be selected it you right-clicked on an element and selected “inspect”)
- `$1` - `$4`: A history of selections (previous values of `$0`) where `$1` is the selection prior to the current `$0` and `$2` is the selection prior to that, etc.
- `$_`: A reference to the last result evaluated in the console

```javascript
// In JavaScript Console
// HTML: <input value="3">
$('input'); // <ENTER>
// <- <input value="3">
$_.value // <ENTER>
// <- "3"

```

Browser support for these command line APIs may vary (these specifically reference Chromium implementations), so you may need to check to see what works in your browser.

More info:

- [Console Utilities on Google Dev](https://developers.google.com/web/tools/chrome-devtools/console/utilities)
