Plenty of π
Module 1: Introduction to JavaScript and Programming
Running JavaScript in Browser Console

The browser's developer console is an invaluable tool for learning and debugging JavaScript.

How to open the console:

  • Chrome: Right-click on a webpage → "Inspect" → "Console" tab. Or Ctrl+Shift+J (Windows/Linux) / Cmd+Option+J (Mac).
  • Firefox: Right-click → "Inspect Element" → "Console" tab. Or Ctrl+Shift+K (Windows/Linux) / Cmd+Option+K (Mac).
  • Edge: Right-click → "Inspect" → "Console" tab. Or F12 then select "Console".
  • Safari: You might need to enable the Develop menu first (Safari Preferences → Advanced → "Show Develop menu in menu bar"). Then Develop → "Show JavaScript Console".

Using the Console:

  • Executing Code: You can type any valid JavaScript expression or statement directly into the console and press Enter to execute it.
    10 + 5 // Output: 15
    let message = "Testing console";
    console.log(message); // Output: Testing console
    
  • Viewing console.log() Output: Messages from console.log() statements in your scripts will appear here.
  • Inspecting Variables: If your script has run and defined global variables, you can type their names into the console to see their current values.
  • Error Messages: JavaScript errors that occur on the page will be reported in the console, often with line numbers and descriptions to help you debug.