console.log('normal log message')
console.log('%clog message with color', 'color: blue')
console.log('%clog message with not one color, %cbut two!', 'color:blue', 'color:red')
console.log('%clog message with background color and padding', 'color:white, background-color:blue, padding: 6px')
Instead of this:
console.log("This is myValue:", myValue);
=> This is myValue: 3
Do this:
console.log({myValue});
=> {myValue: 3}
Logging multiple values?
console.log({myValue, anotherValueThatIsAlsoMine});
=> {myValue: 3, anotherValueThatIsAlsoMine: "also 3"}
No need to add console.log
statements to your code to log values. Instead:
- find your code in the dev console (Sources tab)
- right-click the line number
- select Add logpoint...
- enter the label or value you want to log.
- if logging a value, enclose it in curly brackets
{myValue}
- if logging a value, enclose it in curly brackets
- refresh!
ymmv: it's a little tedious to find the right spot in code, right-click, etc., but it saves some cleanup