Using Chrome DevTools Console Shortcuts: $, $$, $_, and $i

This article introduces Chrome DevTools console shortcuts—including $0‑$4 for element references, $ and $$ for query selectors, $_ for the last expression result, and $i for importing npm libraries—explaining their usage to streamline front‑end debugging and testing.

UC Tech Team
UC Tech Team
UC Tech Team
Using Chrome DevTools Console Shortcuts: $, $$, $_, and $i

This article is the first in a 24‑day series sharing concise DevTools tips, focusing on console shortcuts that make front‑end debugging more efficient.

The variables $0, $1, $2, $3 and $4 reference the currently selected HTML node and the previous selections in the Elements panel, allowing quick manipulation such as $1.appendChild($0).

The single‑character $ is a shorthand for document.querySelector, while $$ is a shortcut for document.querySelectorAll that returns an array; for example Array.from(document.querySelectorAll('div')) === $$("div").

The $_ variable stores the result of the last evaluated expression, enabling you to reuse that value without re‑typing the expression.

With the Chrome Console Importer extension, the $i command lets you import and run npm packages directly in the console, e.g., $i('lodash') or $i('moment'), fetching the library within seconds.

The article concludes by noting that these shortcuts provide a compact, powerful way to interact with the page during development.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

debuggingfrontendJavaScriptChrome DevToolsconsole
UC Tech Team
Written by

UC Tech Team

We provide high-quality technical articles on client, server, algorithms, testing, data, front-end, and more, including both original and translated content.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.