
Similarly, autocompletion keeps a history of the commands you previously typed. Press Up Arrow to display the commands that you entered previously. to get a large list of possible properties and methods available on the body of the current webpage.Īs with many other command-line environments, a history of the commands that you entered is available for reuse. Press the arrow keys to highlight document on the dropdown menu. To try autocompletion while writing multi-part expressions: This feature is a great way to learn about JavaScript methods that you didn't know of before. The Console helps you write complex JavaScript using autocompletion. When you press Enter, the Console runs the JavaScript command (expression or statement), displays the result, and then moves the cursor down to allow you to enter the next JavaScript command.Īutocompletion to write complex expressions The Console displays the result while you type, regardless of whether your JavaScript is correct, and regardless of whether a valid result exists. The Eager evaluation feature helps you write valid JavaScript. The Console immediately displays the result 4 on the next line while you type. If necessary, click in DevTools to give it focus, and then press Esc to open the Console.Ĭlick in the Console, and then type 2+2, without pressing Enter. Or, press Ctrl+ Shift+ J (Windows, Linux) or Command+ Option+ J (macOS), to directly open the DevTools console. Right-click in a webpage and then select Inspect. To enter JavaScript statements and expressions interactively in the Console:



REPL stands for Read, Evaluate, Print, and Loop.

This is possible because the Console tool in DevTools is a REPL environment. You can enter any JavaScript expression, statement, or code snippet in the Console, and it runs immediately and interactively as you type.
