console.log statements. They are life savers to identify logic-based issues in code.
But there is a limitation here. You'll need to modify code to add console statements in order to verify values (another option being adding breakpoints).
But, that's no more true.
Chrome now allows you to add logging statements without actually adding it in your code. And they call it logpoints.
In order for you to add a logpoint, open up the code where you need to log and right-click on line number. Select "Add logpoint" option and enter the list of variables/values to be logged (separated by comma).
Once set, Chrome will log the values to console each time the line is executed. 🥳
Preview (logging without console logs):
Try it yourself at Lessons: Conditional Breakpoints (Demo Page)
You can also clone the repo below and run the same in your local machine.
Chrome DevTools Guide
Consists of files to learn the usage of various functions in Chrome DevTools
Clone the repo to your local machine and open the appropriate file in browser.
git clone https://github.com/apvarun/ChromeDevToolsGuide.git
This project is licensed under the MIT License - see the LICENSE.md file for details
Previous Post: Conditional Breakpoints