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)

PPTX
ai tools demonstartion for schools and inter college
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
System and Network Administraation Chapter 3
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
Transform Your Business with a Software ERP System
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
top salesforce developer skills in 2025.pdf
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
 
PPTX
Reimagine Home Health with the Power of Agentic AI​
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
AI in Product Development-omnex systems
PDF
Understanding Forklifts - TECH EHS Solution
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
ai tools demonstartion for schools and inter college
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
System and Network Administraation Chapter 3
Odoo Companies in India – Driving Business Transformation.pdf
Wondershare Filmora 15 Crack With Activation Key [2025
Transform Your Business with a Software ERP System
Softaken Excel to vCard Converter Software.pdf
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
top salesforce developer skills in 2025.pdf
Upgrade and Innovation Strategies for SAP ERP Customers
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
 
Reimagine Home Health with the Power of Agentic AI​
VVF-Customer-Presentation2025-Ver1.9.pptx
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Design an Analysis of Algorithms I-SECS-1021-03
AI in Product Development-omnex systems
Understanding Forklifts - TECH EHS Solution
How to Migrate SBCGlobal Email to Yahoo Easily
2025 Textile ERP Trends: SAP, Odoo & Oracle

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.