

The Console prints the result of the expression below your code. The result 20 will appear below your expression (unless your expression takes too much time to evaluate). The Console is a perfect place for these kinds of experiments. Sometimes, you just want a code playground where you can test some code, or try out new JavaScript features you're not familiar with. # Run arbitrary JavaScript that's not related to the page So "Hello, Console!" must be the result of evaluating document.getElementById('hello').textContent = 'Hello, Console!'. After evaluating your code, a REPL prints the result of the expression. Recall the 4 steps of REPL: read, evaluate, print, loop.

How the Console looks after evaluating the expression above.īelow the code that you evaluated you see "Hello, Console!". Notice how the text inside the button changes.įigure 3. Type document.getElementById('hello').textContent = 'Hello, Console!' in the Console and then press Enter to evaluate the expression. When building or debugging a page, it's often useful to run statements in the Console in order to change how the page looks or runs. # View and change the page's JavaScript or DOM This tutorial on the left, and DevTools on the right. Press Command+Option+J (Mac) or Control+Shift+J (Windows, Linux, ChromeOS) to open the Console, right here on this very page.įigure 2. When you physically follow along, you're more likely to remember the workflows later. This tutorial is designed so that you can open up the demo and try all the workflows yourself. It reads the JavaScript that you type into it, evaluates your code, prints out the result of your expression, and then loops back to the first step. The Console is a REPL, which stands for Read, Evaluate, Print, and Loop. See Get Started With Debugging JavaScript to learn how to pause JavaScript code and step through it one line at a time.

See Get Started With Logging Messages to learn how to log messages to the Console. This interactive tutorial shows you how to run JavaScript in the Chrome DevTools Console.
