2. Formatting Logs:
There is a way to print out objects in a nice formatted
way using console.dir().
For example,
const jsNugget = {
topic: 'Logging',
platform: 'Javascript',
date: {
year: '2020',
month: 'February',
day: 'Wednesday'
}
};
console.dir(jsNugget);
Output:
3. Formatting Logs:
You can print out a DOM element’s markup in a formatted
way using console.dirxml().
For example,
<body>
<h1>hello</h1>
<script>
console.dirxml(document.body);
</script>
</body>
Output:
4. Clearing the logs:
You can clear out all the console logs using the
console.clear() method.
Countings:
The console.count() method is used to count the number
of times it has been invoked with the same provided
label.
For example, here we have two counters, one for even
values and one for odd values
[1, 2, 3, 4, 5].forEach(nb => {
if (nb % 2 === 0) {
console.count('even');
} else {
console.count('odd');
}
});
// odd: 1
// even: 1
// odd: 2
// even: 2
// odd: 3
5. That you can play around with console, in the
forthcoming parts.