Using the console to log some information is a very common way to debug your JavaScript. But you can also log information in any web site using Logpoints in the sources panel.
Here's how to do it:
- In the Sources panel (or Debugger in Firefox), open a JavaScript file and right-click any line number.
- Select
Add logpoint
to open the editor - In the editor, enter the JavaScript expression you'd like to log.
- Hit Enter to save and a badge shows on the line number.
- Go to the console, interact with the site and every time this line executes, you see the result of the logpoint expression.
- If you don't want to log information any longer, click the Logpoint again to remove it.
Logpoints are a way to inject a console.log()
into any web site without editing its source code.
You can see this in action in this video on YouTube: