SlideShare a Scribd company logo
LOGGING
IN JAVASCRIPT
PART 2
console:
With the console object and its logging methods, long
are the days of calling alert() to debug and get a
variable’s value.
Besides the general logging methods that we have
discussed in the previous part, there are few more
methods that we can play around with.
We will cover the below two in this part.
- Stack Tracing
- Asserting
Stack Tracing:
The console.trace() method displays a trace that show
how the code ended up at a certain point.
Take a look at the below example, to understand how
console.trace() works.
function hello(name) {
console.trace('name:', name);
return `Hello ${name}!`;
}
hello('JS Nugget');
Output:
Asserting:
The console.assert method is an easy way to run
assertion tests. If the assertion of the 1st argument
fails, the subsequent argument gets printed to the
console.
Let’s look at this example,
// this will pass, nothing will be logged
console.assert(1 == '1', '1 not == to "1"');
Output:
// this will pass, nothing will be logged
console.assert(1 === '1', '1 not == to "1"');
The below assertion fails,
STAY AROUND FOR
OTHER TRICKS!
That you can play around with console, in the
forthcoming parts.

More Related Content

What's hot (20)

Rust-lang
Rust-lang
Anthony Broad-Crawford
 
Multimethods
Multimethods
Aman King
 
Planet of the AOPs
Planet of the AOPs
James Ward
 
[ASM]Lab6
[ASM]Lab6
Nora Youssef
 
[ASM]Lab5
[ASM]Lab5
Nora Youssef
 
Rust: код может быть одновременно безопасным и быстрым, Степан Кольцов
Rust: код может быть одновременно безопасным и быстрым, Степан Кольцов
Yandex
 
Modern Objective-C @ Pragma Night
Modern Objective-C @ Pragma Night
Giuseppe Arici
 
New features and enhancement
New features and enhancement
Rakesh Madugula
 
Java lejos-multithreading
Java lejos-multithreading
Mr. Chanuwan
 
Rust Synchronization Primitives
Rust Synchronization Primitives
Corey Richardson
 
Python Programming Essentials - M5 - Variables
Python Programming Essentials - M5 - Variables
P3 InfoTech Solutions Pvt. Ltd.
 
Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"
Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"
OdessaJS Conf
 
GeoGebra JavaScript CheatSheet
GeoGebra JavaScript CheatSheet
Jose Perez
 
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
OdessaJS Conf
 
TLPI - 6 Process
TLPI - 6 Process
Shu-Yu Fu
 
The best of AltJava is Xtend
The best of AltJava is Xtend
takezoe
 
Ruby Code Optimizations (for beginners)
Ruby Code Optimizations (for beginners)
chirantan.rajhans
 
Loops
Loops
EMAD ALHOTHLY
 
Write a program that performs the brute force attack to break the pa
Write a program that performs the brute force attack to break the pa
ssuser774ad41
 
Reconstruction
Reconstruction
COMSATS Abbottabad
 
Multimethods
Multimethods
Aman King
 
Planet of the AOPs
Planet of the AOPs
James Ward
 
Rust: код может быть одновременно безопасным и быстрым, Степан Кольцов
Rust: код может быть одновременно безопасным и быстрым, Степан Кольцов
Yandex
 
Modern Objective-C @ Pragma Night
Modern Objective-C @ Pragma Night
Giuseppe Arici
 
New features and enhancement
New features and enhancement
Rakesh Madugula
 
Java lejos-multithreading
Java lejos-multithreading
Mr. Chanuwan
 
Rust Synchronization Primitives
Rust Synchronization Primitives
Corey Richardson
 
Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"
Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"
OdessaJS Conf
 
GeoGebra JavaScript CheatSheet
GeoGebra JavaScript CheatSheet
Jose Perez
 
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
OdessaJS Conf
 
TLPI - 6 Process
TLPI - 6 Process
Shu-Yu Fu
 
The best of AltJava is Xtend
The best of AltJava is Xtend
takezoe
 
Ruby Code Optimizations (for beginners)
Ruby Code Optimizations (for beginners)
chirantan.rajhans
 
Write a program that performs the brute force attack to break the pa
Write a program that performs the brute force attack to break the pa
ssuser774ad41
 

Similar to Logging in JavaScript - part-2 (20)

Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1
Troy Miles
 
Weird Javascript Weekends first session presentaion
Weird Javascript Weekends first session presentaion
SrishtyMangutte
 
JS Control Statements and Functions.pptx
JS Control Statements and Functions.pptx
Ramakrishna Reddy Bijjam
 
JAVA LESSON-02.pptx
JAVA LESSON-02.pptx
StephenOczon1
 
[2012 02 03]clean_code 4장
[2012 02 03]clean_code 4장
Jong Pil Won
 
Explanations to the article on Copy-Paste
Explanations to the article on Copy-Paste
PVS-Studio
 
Unit2_3.pptx Chapter 2 Introduction to C#
Unit2_3.pptx Chapter 2 Introduction to C#
Priyanka Jadhav
 
Kamil witecki asynchronous, yet readable, code
Kamil witecki asynchronous, yet readable, code
Kamil Witecki
 
Java 17
Java 17
Mutlu Okuducu
 
Heading for a Record: Chromium, the 5th Check
Heading for a Record: Chromium, the 5th Check
PVS-Studio
 
Checking Clang 11 with PVS-Studio
Checking Clang 11 with PVS-Studio
Andrey Karpov
 
00_Introduction to Java.ppt
00_Introduction to Java.ppt
HongAnhNguyn285885
 
Repetition Structure
Repetition Structure
PRN USM
 
Objectives Assignment 09 Applications of Stacks COS.docx
Objectives Assignment 09 Applications of Stacks COS.docx
dunhamadell
 
JavaScript Editions ES7, ES8 and ES9 vs V8
JavaScript Editions ES7, ES8 and ES9 vs V8
Rafael Casuso Romate
 
Vb script tutorial
Vb script tutorial
Abhishek Kesharwani
 
Getting started with ES6
Getting started with ES6
Nitay Neeman
 
Bluespec Tutorial Helloworld
Bluespec Tutorial Helloworld
Stanley Ho
 
15646254 c-balaguruswamy-solved-programs
15646254 c-balaguruswamy-solved-programs
premrings
 
CMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docx
CMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docx
monicafrancis71118
 
Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1
Troy Miles
 
Weird Javascript Weekends first session presentaion
Weird Javascript Weekends first session presentaion
SrishtyMangutte
 
[2012 02 03]clean_code 4장
[2012 02 03]clean_code 4장
Jong Pil Won
 
Explanations to the article on Copy-Paste
Explanations to the article on Copy-Paste
PVS-Studio
 
Unit2_3.pptx Chapter 2 Introduction to C#
Unit2_3.pptx Chapter 2 Introduction to C#
Priyanka Jadhav
 
Kamil witecki asynchronous, yet readable, code
Kamil witecki asynchronous, yet readable, code
Kamil Witecki
 
Heading for a Record: Chromium, the 5th Check
Heading for a Record: Chromium, the 5th Check
PVS-Studio
 
Checking Clang 11 with PVS-Studio
Checking Clang 11 with PVS-Studio
Andrey Karpov
 
Repetition Structure
Repetition Structure
PRN USM
 
Objectives Assignment 09 Applications of Stacks COS.docx
Objectives Assignment 09 Applications of Stacks COS.docx
dunhamadell
 
JavaScript Editions ES7, ES8 and ES9 vs V8
JavaScript Editions ES7, ES8 and ES9 vs V8
Rafael Casuso Romate
 
Getting started with ES6
Getting started with ES6
Nitay Neeman
 
Bluespec Tutorial Helloworld
Bluespec Tutorial Helloworld
Stanley Ho
 
15646254 c-balaguruswamy-solved-programs
15646254 c-balaguruswamy-solved-programs
premrings
 
CMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docx
CMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docx
monicafrancis71118
 
Ad

More from Ideas2IT Technologies (20)

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

Recently uploaded (20)

Software Engineering Process, Notation & Tools Introduction - Part 4
Software Engineering Process, Notation & Tools Introduction - Part 4
Gaurav Sharma
 
How Insurance Policy Management Software Streamlines Operations
How Insurance Policy Management Software Streamlines Operations
Insurance Tech Services
 
Advanced Token Development - Decentralized Innovation
Advanced Token Development - Decentralized Innovation
arohisinghas720
 
Smart Financial Solutions: Money Lender Software, Daily Pigmy & Personal Loan...
Smart Financial Solutions: Money Lender Software, Daily Pigmy & Personal Loan...
Intelli grow
 
Software Testing & it’s types (DevOps)
Software Testing & it’s types (DevOps)
S Pranav (Deepu)
 
How the US Navy Approaches DevSecOps with Raise 2.0
How the US Navy Approaches DevSecOps with Raise 2.0
Anchore
 
Women in Tech: Marketo Engage User Group - June 2025 - AJO with AWS
Women in Tech: Marketo Engage User Group - June 2025 - AJO with AWS
BradBedford3
 
Zoneranker’s Digital marketing solutions
Zoneranker’s Digital marketing solutions
reenashriee
 
GDG Douglas - Google AI Agents: Your Next Intern?
GDG Douglas - Google AI Agents: Your Next Intern?
felipeceotto
 
wAIred_RabobankIgniteSession_12062025.pptx
wAIred_RabobankIgniteSession_12062025.pptx
SimonedeGijt
 
Software Engineering Process, Notation & Tools Introduction - Part 3
Software Engineering Process, Notation & Tools Introduction - Part 3
Gaurav Sharma
 
Artificial Intelligence Applications Across Industries
Artificial Intelligence Applications Across Industries
SandeepKS52
 
UPDASP a project coordination unit ......
UPDASP a project coordination unit ......
withrj1
 
Plooma is a writing platform to plan, write, and shape books your way
Plooma is a writing platform to plan, write, and shape books your way
Plooma
 
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
usmanch7829
 
AI-Powered Compliance Solutions for Global Regulations | Certivo
AI-Powered Compliance Solutions for Global Regulations | Certivo
certivoai
 
Meet You in the Middle: 1000x Performance for Parquet Queries on PB-Scale Dat...
Meet You in the Middle: 1000x Performance for Parquet Queries on PB-Scale Dat...
Alluxio, Inc.
 
AI and Deep Learning with NVIDIA Technologies
AI and Deep Learning with NVIDIA Technologies
SandeepKS52
 
What is data visualization and how data visualization tool can help.pdf
What is data visualization and how data visualization tool can help.pdf
Varsha Nayak
 
SAP PM Module Level-IV Training Complete.ppt
SAP PM Module Level-IV Training Complete.ppt
MuhammadShaheryar36
 
Software Engineering Process, Notation & Tools Introduction - Part 4
Software Engineering Process, Notation & Tools Introduction - Part 4
Gaurav Sharma
 
How Insurance Policy Management Software Streamlines Operations
How Insurance Policy Management Software Streamlines Operations
Insurance Tech Services
 
Advanced Token Development - Decentralized Innovation
Advanced Token Development - Decentralized Innovation
arohisinghas720
 
Smart Financial Solutions: Money Lender Software, Daily Pigmy & Personal Loan...
Smart Financial Solutions: Money Lender Software, Daily Pigmy & Personal Loan...
Intelli grow
 
Software Testing & it’s types (DevOps)
Software Testing & it’s types (DevOps)
S Pranav (Deepu)
 
How the US Navy Approaches DevSecOps with Raise 2.0
How the US Navy Approaches DevSecOps with Raise 2.0
Anchore
 
Women in Tech: Marketo Engage User Group - June 2025 - AJO with AWS
Women in Tech: Marketo Engage User Group - June 2025 - AJO with AWS
BradBedford3
 
Zoneranker’s Digital marketing solutions
Zoneranker’s Digital marketing solutions
reenashriee
 
GDG Douglas - Google AI Agents: Your Next Intern?
GDG Douglas - Google AI Agents: Your Next Intern?
felipeceotto
 
wAIred_RabobankIgniteSession_12062025.pptx
wAIred_RabobankIgniteSession_12062025.pptx
SimonedeGijt
 
Software Engineering Process, Notation & Tools Introduction - Part 3
Software Engineering Process, Notation & Tools Introduction - Part 3
Gaurav Sharma
 
Artificial Intelligence Applications Across Industries
Artificial Intelligence Applications Across Industries
SandeepKS52
 
UPDASP a project coordination unit ......
UPDASP a project coordination unit ......
withrj1
 
Plooma is a writing platform to plan, write, and shape books your way
Plooma is a writing platform to plan, write, and shape books your way
Plooma
 
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
usmanch7829
 
AI-Powered Compliance Solutions for Global Regulations | Certivo
AI-Powered Compliance Solutions for Global Regulations | Certivo
certivoai
 
Meet You in the Middle: 1000x Performance for Parquet Queries on PB-Scale Dat...
Meet You in the Middle: 1000x Performance for Parquet Queries on PB-Scale Dat...
Alluxio, Inc.
 
AI and Deep Learning with NVIDIA Technologies
AI and Deep Learning with NVIDIA Technologies
SandeepKS52
 
What is data visualization and how data visualization tool can help.pdf
What is data visualization and how data visualization tool can help.pdf
Varsha Nayak
 
SAP PM Module Level-IV Training Complete.ppt
SAP PM Module Level-IV Training Complete.ppt
MuhammadShaheryar36
 

Logging in JavaScript - part-2

  • 2. console: With the console object and its logging methods, long are the days of calling alert() to debug and get a variable’s value. Besides the general logging methods that we have discussed in the previous part, there are few more methods that we can play around with. We will cover the below two in this part. - Stack Tracing - Asserting
  • 3. Stack Tracing: The console.trace() method displays a trace that show how the code ended up at a certain point. Take a look at the below example, to understand how console.trace() works. function hello(name) { console.trace('name:', name); return `Hello ${name}!`; } hello('JS Nugget'); Output:
  • 4. Asserting: The console.assert method is an easy way to run assertion tests. If the assertion of the 1st argument fails, the subsequent argument gets printed to the console. Let’s look at this example, // this will pass, nothing will be logged console.assert(1 == '1', '1 not == to "1"'); Output: // this will pass, nothing will be logged console.assert(1 === '1', '1 not == to "1"'); The below assertion fails,
  • 5. STAY AROUND FOR OTHER TRICKS! That you can play around with console, in the forthcoming parts.