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
Logging in JavaScript - Part-4
Ideas2IT Technologies
 
PDF
Fb cheatsheet12b
ilesh raval
 
PPTX
Getting started with ES6
Nitay Neeman
 
PPTX
JavaScript DOM - Dynamic interactive Code
Laurence Svekis ✔
 
PPTX
Class[3][5th jun] [three js]
Saajid Akram
 
DOCX
What are arrays in java script
Miguel Silva Loureiro
 
PPT
Javascript Primer
Adam Hepton
 
PDF
Angular Weekend
Troy Miles
 
PDF
React Development with the MERN Stack
Troy Miles
 
PDF
Modern JavaScript Programming
Wildan Maulana
 
PDF
Node Boot Camp
Troy Miles
 
PPTX
Web technologies-course 12.pptx
Stefan Oprea
 
PDF
Logging in JavaScript - part-2
Ideas2IT Technologies
 
PPTX
Console in javaScript
Vivek Kumar
 
KEY
JavaScript Growing Up
David Padbury
 
PPTX
Java script
Adrian Caetano
 
PDF
Javascript
Vlad Ifrim
 
PPTX
JavaScript Core fundamentals - Learn JavaScript Here
Laurence Svekis ✔
 
PDF
React Native Evening
Troy Miles
 
PDF
Underscore.js
timourian
 
Logging in JavaScript - Part-4
Ideas2IT Technologies
 
Fb cheatsheet12b
ilesh raval
 
Getting started with ES6
Nitay Neeman
 
JavaScript DOM - Dynamic interactive Code
Laurence Svekis ✔
 
Class[3][5th jun] [three js]
Saajid Akram
 
What are arrays in java script
Miguel Silva Loureiro
 
Javascript Primer
Adam Hepton
 
Angular Weekend
Troy Miles
 
React Development with the MERN Stack
Troy Miles
 
Modern JavaScript Programming
Wildan Maulana
 
Node Boot Camp
Troy Miles
 
Web technologies-course 12.pptx
Stefan Oprea
 
Logging in JavaScript - part-2
Ideas2IT Technologies
 
Console in javaScript
Vivek Kumar
 
JavaScript Growing Up
David Padbury
 
Java script
Adrian Caetano
 
Javascript
Vlad Ifrim
 
JavaScript Core fundamentals - Learn JavaScript Here
Laurence Svekis ✔
 
React Native Evening
Troy Miles
 
Underscore.js
timourian
 
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-1
Ideas2IT Technologies
 
PDF
Array vs set in JavaScript
Ideas2IT Technologies
 
PDF
Arguments Object in JavaScript
Ideas2IT Technologies
 
PDF
Pollyfills 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-1
Ideas2IT Technologies
 
Array vs set in JavaScript
Ideas2IT Technologies
 
Arguments Object in JavaScript
Ideas2IT Technologies
 
Pollyfills in JavaScript
Ideas2IT Technologies
 
Ad

Recently uploaded (20)

DOCX
Import Data Form Excel to Tally Services
Tally xperts
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PDF
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PPTX
Coefficient of Variance in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Mobile CMMS Solutions Empowering the Frontline Workforce
CryotosCMMSSoftware
 
PDF
Online Queue Management System for Public Service Offices in Nepal [Focused i...
Rishab Acharya
 
PPTX
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
PDF
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PDF
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PPTX
Fundamentals_of_Microservices_Architecture.pptx
MuhammadUzair504018
 
PPTX
Human Resources Information System (HRIS)
Amity University, Patna
 
PDF
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PPTX
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
PPTX
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
PDF
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
Import Data Form Excel to Tally Services
Tally xperts
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
Coefficient of Variance in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Mobile CMMS Solutions Empowering the Frontline Workforce
CryotosCMMSSoftware
 
Online Queue Management System for Public Service Offices in Nepal [Focused i...
Rishab Acharya
 
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
Fundamentals_of_Microservices_Architecture.pptx
MuhammadUzair504018
 
Human Resources Information System (HRIS)
Amity University, Patna
 
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 

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.