SlideShare a Scribd company logo
Logging in JavaScript - Part-3
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:
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:
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
That you can play around with console, in the
forthcoming parts.

More Related Content

DOCX
Conversion of data types in java
PPT
Building Your First MongoDB Application (Mongo Austin)
PPT
Building Applications with MongoDB - an Introduction
DOCX
A Shiny Example-- R
PPT
Building a web application with mongo db
DOC
Rumus visual basic
PPT
Nosh slides mongodb web application - mongo philly 2011
PDF
Richard Salter: Using the Titanium OpenGL Module
Conversion of data types in java
Building Your First MongoDB Application (Mongo Austin)
Building Applications with MongoDB - an Introduction
A Shiny Example-- R
Building a web application with mongo db
Rumus visual basic
Nosh slides mongodb web application - mongo philly 2011
Richard Salter: Using the Titanium OpenGL Module

What's hot (20)

DOC
Rumus VB Menghitung Nilai Persamaan
DOCX
Doubly linklist
PDF
The Ring programming language version 1.2 book - Part 29 of 84
PPT
Measuring SGX Texturing Performance
DOC
Rumus VB-2
DOCX
Oop lab report
PPTX
2 18-2018-all teams total runs
PDF
Coding with Vim
PDF
Om (Cont.)
PDF
Bitcoin:Next
KEY
cocos2d 事例編 HungryMasterの実装から
PDF
Community-driven Language Design at TC39 on the JavaScript Pipeline Operator ...
PDF
Script for Spatial Mongo
KEY
Mysql 4.0 casual
PDF
Linux Shell (Expiry of Domain and Certificate)
PDF
The Ring programming language version 1.5.2 book - Part 40 of 181
PDF
Statistics.cpp
Rumus VB Menghitung Nilai Persamaan
Doubly linklist
The Ring programming language version 1.2 book - Part 29 of 84
Measuring SGX Texturing Performance
Rumus VB-2
Oop lab report
2 18-2018-all teams total runs
Coding with Vim
Om (Cont.)
Bitcoin:Next
cocos2d 事例編 HungryMasterの実装から
Community-driven Language Design at TC39 on the JavaScript Pipeline Operator ...
Script for Spatial Mongo
Mysql 4.0 casual
Linux Shell (Expiry of Domain and Certificate)
The Ring programming language version 1.5.2 book - Part 40 of 181
Statistics.cpp
Ad

Similar to Logging in JavaScript - Part-3 (20)

PDF
Book
DOCX
1- Create a Visual Calculator by using winform application in Microsof.docx
PPTX
Getting Input from User
PPTX
Unit-2 Getting Input from User.pptx
PDF
Logging in JavaScript - Part-4
PDF
Basics of google chrome developer tools
PDF
full stack modul 5, mongodb,webpack,front-end,back-end
PPTX
Javascript note for engineering notes.pptx
DOCX
Programming Assignment- Building a functional program Here are my err.docx
PPTX
C# PPT FPR STUFENTS NOTES PPT FILES STUDY
PPTX
Sekilas PHP + mongoDB
PPTX
Data and time
PDF
Go Programming by Example_ Nho Vĩnh Share.pdf
DOCX
C# console applications.docx
PPTX
Js tutorial(Basic concepts, running a program ,console,variable,types etc..)
PDF
c++ referesher 1.pdf
DOCX
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
PPT
This is a python. Ppt it is used for bca student also.
DOCX
Final Project SkeletonCipherClient.javaFinal Project SkeletonC.docx
PDF
Visual Programming Lacture Nine 9 Structure.pdf
Book
1- Create a Visual Calculator by using winform application in Microsof.docx
Getting Input from User
Unit-2 Getting Input from User.pptx
Logging in JavaScript - Part-4
Basics of google chrome developer tools
full stack modul 5, mongodb,webpack,front-end,back-end
Javascript note for engineering notes.pptx
Programming Assignment- Building a functional program Here are my err.docx
C# PPT FPR STUFENTS NOTES PPT FILES STUDY
Sekilas PHP + mongoDB
Data and time
Go Programming by Example_ Nho Vĩnh Share.pdf
C# console applications.docx
Js tutorial(Basic concepts, running a program ,console,variable,types etc..)
c++ referesher 1.pdf
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
This is a python. Ppt it is used for bca student also.
Final Project SkeletonCipherClient.javaFinal Project SkeletonC.docx
Visual Programming Lacture Nine 9 Structure.pdf
Ad

More from Ideas2IT Technologies (20)

PDF
Version comaparison in JavaScript
PDF
Currying in JavaScript
PDF
JS Testing Frameworks
PDF
Cool usage of Encoding and Decoding a URI in Javascript
PDF
Iterables and Iterators in JavaScript
PDF
String comparison in javascript
PDF
JavaScript symbols
PDF
Json.parse() in JavaScript
PDF
Bubble sort in Java Script
PDF
Performance analysis in merging arrays - JavaScript
PDF
Nullish coalescing in JavaScript
PDF
Conditionally add keys in JavaScript
PDF
What is Big O in JavaScript - Part-1
PDF
Variable hoisting in JavaScript
PDF
Formidable ES6 spread operator in JavaScript
PDF
Logging in JavaScript - Part-5
PDF
Logging in JavaScript - part-2
PDF
Logging in JavaScript - part-1
PDF
Array vs set in JavaScript
PDF
Arguments Object in JavaScript
Version comaparison in JavaScript
Currying in JavaScript
JS Testing Frameworks
Cool usage of Encoding and Decoding a URI in Javascript
Iterables and Iterators in JavaScript
String comparison in javascript
JavaScript symbols
Json.parse() in JavaScript
Bubble sort in Java Script
Performance analysis in merging arrays - JavaScript
Nullish coalescing in JavaScript
Conditionally add keys in JavaScript
What is Big O in JavaScript - Part-1
Variable hoisting in JavaScript
Formidable ES6 spread operator in JavaScript
Logging in JavaScript - Part-5
Logging in JavaScript - part-2
Logging in JavaScript - part-1
Array vs set in JavaScript
Arguments Object in JavaScript

Recently uploaded (20)

DOCX
The Five Best AI Cover Tools in 2025.docx
PPTX
Materi_Pemrograman_Komputer-Looping.pptx
PPTX
Transform Your Business with a Software ERP System
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
Digital Strategies for Manufacturing Companies
PDF
AI in Product Development-omnex systems
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
ai tools demonstartion for schools and inter college
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPTX
Odoo POS Development Services by CandidRoot Solutions
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Complete React Javascript Course Syllabus.pdf
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
The Five Best AI Cover Tools in 2025.docx
Materi_Pemrograman_Komputer-Looping.pptx
Transform Your Business with a Software ERP System
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Digital Strategies for Manufacturing Companies
AI in Product Development-omnex systems
Operating system designcfffgfgggggggvggggggggg
ai tools demonstartion for schools and inter college
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
How to Migrate SBCGlobal Email to Yahoo Easily
Odoo POS Development Services by CandidRoot Solutions
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Complete React Javascript Course Syllabus.pdf
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Softaken Excel to vCard Converter Software.pdf
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
How to Choose the Right IT Partner for Your Business in Malaysia
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
VVF-Customer-Presentation2025-Ver1.9.pptx

Logging in JavaScript - Part-3

  • 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.