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

What's hot (20)

DOC
Rumus VB Menghitung Nilai Persamaan
T. Astari
 
DOCX
Doubly linklist
ilsamaryum
 
PDF
The Ring programming language version 1.2 book - Part 29 of 84
Mahmoud Samir Fayed
 
PPT
Measuring SGX Texturing Performance
Prabindh Sundareson
 
DOC
Rumus VB-2
T. Astari
 
DOCX
Oop lab report
khasmanjalali
 
PPTX
2 18-2018-all teams total runs
Alexander Bitar
 
PDF
Coding with Vim
Enzo Wang
 
PDF
Om (Cont.)
Taku Fukushima
 
PDF
Bitcoin:Next
Felix Crisan
 
KEY
cocos2d 事例編 HungryMasterの実装から
Yuichi Higuchi
 
PDF
Community-driven Language Design at TC39 on the JavaScript Pipeline Operator ...
Igalia
 
PDF
Script for Spatial Mongo
Steven Pousty
 
KEY
Mysql 4.0 casual
Masahiro Nagano
 
PDF
Linux Shell (Expiry of Domain and Certificate)
Paulo Paim
 
PDF
The Ring programming language version 1.5.2 book - Part 40 of 181
Mahmoud Samir Fayed
 
PDF
Statistics.cpp
Vorname Nachname
 
Rumus VB Menghitung Nilai Persamaan
T. Astari
 
Doubly linklist
ilsamaryum
 
The Ring programming language version 1.2 book - Part 29 of 84
Mahmoud Samir Fayed
 
Measuring SGX Texturing Performance
Prabindh Sundareson
 
Rumus VB-2
T. Astari
 
Oop lab report
khasmanjalali
 
2 18-2018-all teams total runs
Alexander Bitar
 
Coding with Vim
Enzo Wang
 
Om (Cont.)
Taku Fukushima
 
Bitcoin:Next
Felix Crisan
 
cocos2d 事例編 HungryMasterの実装から
Yuichi Higuchi
 
Community-driven Language Design at TC39 on the JavaScript Pipeline Operator ...
Igalia
 
Script for Spatial Mongo
Steven Pousty
 
Mysql 4.0 casual
Masahiro Nagano
 
Linux Shell (Expiry of Domain and Certificate)
Paulo Paim
 
The Ring programming language version 1.5.2 book - Part 40 of 181
Mahmoud Samir Fayed
 
Statistics.cpp
Vorname Nachname
 

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

PDF
Book
luis_lmro
 
DOCX
1- Create a Visual Calculator by using winform application in Microsof.docx
jbarbara1
 
PPTX
Getting Input from User
Lovely Professional University
 
PPTX
Unit-2 Getting Input from User.pptx
Lovely Professional University
 
PDF
Logging in JavaScript - Part-4
Ideas2IT Technologies
 
PDF
Basics of google chrome developer tools
Digital Shende
 
PPTX
Javascript note for engineering notes.pptx
engineeradda55
 
DOCX
Programming Assignment- Building a functional program Here are my err.docx
LukeQVdGrantg
 
PPTX
C# PPT FPR STUFENTS NOTES PPT FILES STUDY
drpiyushkumarpareek2
 
PPTX
Sekilas PHP + mongoDB
Hadi Ariawan
 
PPTX
Data and time
kajal supernova
 
PDF
Go Programming by Example_ Nho Vĩnh Share.pdf
Nho Vĩnh
 
DOCX
C# console applications.docx
MehwishKanwal14
 
PPTX
Js tutorial(Basic concepts, running a program ,console,variable,types etc..)
reshmy12
 
PDF
c++ referesher 1.pdf
AnkurSingh656748
 
DOCX
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
eugeniadean34240
 
DOCX
Final Project SkeletonCipherClient.javaFinal Project SkeletonC.docx
voversbyobersby
 
PPTX
About the C Libraries which are essential
KakashiiHatake3
 
PDF
C++ L09-Classes Part2
Mohammad Shaker
 
PPTX
Windows PowerShell
Sandun Perera
 
Book
luis_lmro
 
1- Create a Visual Calculator by using winform application in Microsof.docx
jbarbara1
 
Getting Input from User
Lovely Professional University
 
Unit-2 Getting Input from User.pptx
Lovely Professional University
 
Logging in JavaScript - Part-4
Ideas2IT Technologies
 
Basics of google chrome developer tools
Digital Shende
 
Javascript note for engineering notes.pptx
engineeradda55
 
Programming Assignment- Building a functional program Here are my err.docx
LukeQVdGrantg
 
C# PPT FPR STUFENTS NOTES PPT FILES STUDY
drpiyushkumarpareek2
 
Sekilas PHP + mongoDB
Hadi Ariawan
 
Data and time
kajal supernova
 
Go Programming by Example_ Nho Vĩnh Share.pdf
Nho Vĩnh
 
C# console applications.docx
MehwishKanwal14
 
Js tutorial(Basic concepts, running a program ,console,variable,types etc..)
reshmy12
 
c++ referesher 1.pdf
AnkurSingh656748
 
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
eugeniadean34240
 
Final Project SkeletonCipherClient.javaFinal Project SkeletonC.docx
voversbyobersby
 
About the C Libraries which are essential
KakashiiHatake3
 
C++ L09-Classes Part2
Mohammad Shaker
 
Windows PowerShell
Sandun Perera
 
Ad

More from Ideas2IT Technologies (20)

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

Recently uploaded (20)

PPTX
Perfecting XM Cloud for Multisite Setup.pptx
Ahmed Okour
 
PDF
IObit Uninstaller Pro 14.3.1.8 Crack for Windows Latest
utfefguu
 
PDF
LPS25 - Operationalizing MLOps in GEP - Terradue.pdf
terradue
 
PDF
Difference Between Kubernetes and Docker .pdf
Kindlebit Solutions
 
PDF
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
PDF
65811_Introducing the Fusion AI Agent Studio (1).pdf
g6129590
 
PPTX
Comprehensive Guide: Shoviv Exchange to Office 365 Migration Tool 2025
Shoviv Software
 
PDF
capitulando la keynote de GrafanaCON 2025 - Madrid
Imma Valls Bernaus
 
PPTX
Iobit Driver Booster Pro 12 Crack Free Download
chaudhryakashoo065
 
PPTX
A Complete Guide to Salesforce SMS Integrations Build Scalable Messaging With...
360 SMS APP
 
PDF
Code Once; Run Everywhere - A Beginner’s Journey with React Native
Hasitha Walpola
 
PPTX
NeuroStrata: Harnessing Neuro-Symbolic Paradigms for Improved Testability and...
Ivan Ruchkin
 
PDF
Laboratory Workflows Digitalized and live in 90 days with Scifeon´s SAPPA P...
info969686
 
PPTX
CONCEPT OF PROGRAMMING in language .pptx
tamim41
 
PPTX
ManageIQ - Sprint 265 Review - Slide Deck
ManageIQ
 
PDF
WholeClear Split vCard Software for Split large vCard file
markwillsonmw004
 
PPTX
IObit Driver Booster Pro 12.4-12.5 license keys 2025-2026
chaudhryakashoo065
 
PPTX
MiniTool Power Data Recovery Full Crack Latest 2025
muhammadgurbazkhan
 
PDF
>Nitro Pro Crack 14.36.1.0 + Keygen Free Download [Latest]
utfefguu
 
PDF
2025年 Linux 核心專題: 探討 sched_ext 及機器學習.pdf
Eric Chou
 
Perfecting XM Cloud for Multisite Setup.pptx
Ahmed Okour
 
IObit Uninstaller Pro 14.3.1.8 Crack for Windows Latest
utfefguu
 
LPS25 - Operationalizing MLOps in GEP - Terradue.pdf
terradue
 
Difference Between Kubernetes and Docker .pdf
Kindlebit Solutions
 
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
65811_Introducing the Fusion AI Agent Studio (1).pdf
g6129590
 
Comprehensive Guide: Shoviv Exchange to Office 365 Migration Tool 2025
Shoviv Software
 
capitulando la keynote de GrafanaCON 2025 - Madrid
Imma Valls Bernaus
 
Iobit Driver Booster Pro 12 Crack Free Download
chaudhryakashoo065
 
A Complete Guide to Salesforce SMS Integrations Build Scalable Messaging With...
360 SMS APP
 
Code Once; Run Everywhere - A Beginner’s Journey with React Native
Hasitha Walpola
 
NeuroStrata: Harnessing Neuro-Symbolic Paradigms for Improved Testability and...
Ivan Ruchkin
 
Laboratory Workflows Digitalized and live in 90 days with Scifeon´s SAPPA P...
info969686
 
CONCEPT OF PROGRAMMING in language .pptx
tamim41
 
ManageIQ - Sprint 265 Review - Slide Deck
ManageIQ
 
WholeClear Split vCard Software for Split large vCard file
markwillsonmw004
 
IObit Driver Booster Pro 12.4-12.5 license keys 2025-2026
chaudhryakashoo065
 
MiniTool Power Data Recovery Full Crack Latest 2025
muhammadgurbazkhan
 
>Nitro Pro Crack 14.36.1.0 + Keygen Free Download [Latest]
utfefguu
 
2025年 Linux 核心專題: 探討 sched_ext 及機器學習.pdf
Eric Chou
 

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.