Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

You can start writing JavaScript in a modern browser without creating a project or installing a code editor. Open the browser’s developer tools, select the Console, and enter a small expression such as 2 + 3. The Console evaluates it and shows the result. Then use console.log() to print a value explicitly and inspect what your code is doing.

Open the browser’s JavaScript Console

The Console is an interactive area in browser developer tools where you can enter JavaScript and see what it returns. Chrome describes it as a REPL: “The Console is a REPL, which stands for Read, Evaluate, Print, and Loop.” In practice, you enter code, the browser evaluates it, and you see the result.

Open developer tools and choose the Console tab. The exact menu path and keyboard shortcut depend on your browser and operating system. In Chrome, the documented shortcut is Control+Shift+J on Windows, Linux, and ChromeOS, or Command+Option+J on macOS. You can also use the browser’s menus to open developer tools if the shortcut differs.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For more on Chrome’s Console controls and workflow, see Chrome DevTools: Run JavaScript in the Console. MDN also explains the browser console as a place to enter and run JavaScript in the current page: What are browser developer tools?

Run an expression, then log a value

Start with an expression

Click the Console prompt, type this expression, and press Enter:

2 + 3

The Console evaluates the expression and displays its result, 5. An expression produces a value, so the Console can show that value directly.

Print something with console.log()

Now enter:

console.log("Hello, JavaScript!")

console.log() asks JavaScript to display the value you pass to it. You will see Hello, JavaScript! in the Console. Unlike the bare 2 + 3 expression, this output comes from an explicit logging call in your code.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Try a variable next:

const name = "Ada";
console.log(name);

This creates a constant named name and logs its value. Change "Ada" to another name and run the lines again. If you want to reuse the same const declaration in a Console session, choose a different variable name or reload the page before running it again; a name already declared with const cannot be declared again in the same scope.

Try code that interacts with the current page

A browser Console can do more than calculate values: it can run JavaScript in the context of the page currently open. That means page APIs such as document are available, and code can affect that page.

For example, Chrome’s tutorial demonstrates changing a button’s text with document.getElementById(...).textContent. A safe version to try is:

document.getElementById("myButton").textContent = "Clicked";

Replace myButton with the actual id of a button on the page. If no element has that ID, the lookup returns null, and trying to set textContent will produce an error. The change applies to the currently loaded page; it does not edit the site’s saved source or permanently change the page.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Trace an unexpected result

If the Console does not show what you expect, check the code and the first error message before changing several things at once. Small syntax details are common sources of trouble.

  • Check spelling, including capitalization. JavaScript treats name and Name as different identifiers.
  • Check that parentheses and quotation marks are paired.
  • Read the first error shown; later messages may follow from the original problem.
  • Log intermediate values to see what the code has produced so far.

For example, if a calculation is surprising, assign part of it to a variable and log that value:

const subtotal = 12 * 3;
console.log(subtotal);

MDN describes using console logging to inspect values while debugging. You can also use console.error() to mark an error message clearly; it is another Console method, not a fix for the underlying problem. See MDN: console and MDN: Debugging JavaScript.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Browser Console or Node.js?

Both environments run JavaScript and provide console-style output, but they do not run code in the same context. A browser Console runs against the current page; Node.js runs JavaScript in a Node process, outside that page. The browser is a straightforward place to begin if you want to try expressions or inspect a web page. Node.js is an option when you want to work in its separate runtime.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
What differs Browser DevTools Console Node.js
Execution context The currently loaded browser page. A Node.js process, not the current browser page.
Getting started Available in a modern browser’s developer tools. Requires a Node.js runtime.
APIs Includes page-related APIs such as document when used in a page context. Provides Node-specific runtime APIs; browser page objects such as document are not part of the Node Console context.
Output and debugging Shows expression results and logged values in developer tools, alongside messages for the page. Provides console-style methods in the Node runtime; its output and available debugging context are separate from browser developer tools.

Node.js documents its console API separately from the browser page environment: Node.js v16.20.2 Console. That documentation is for version 16.20.2; do not assume every detail applies identically to other Node versions.