SlideShare a Scribd company logo
1 of 26
Download to read offline
Debugging JavaScript
Client side scripting
Outline
1. Debugging tools
a. Built-ins and beyond, but mostly built-ins

2. Fishbone diagram
3. Debugging workshop
Getting started with debugging JS
1. Brower built-ins
a. Chrome, Safari, Opera, Firefox, IE

2. Browser extension
a. Firebug (lite) (Firefox, IE6+, Opera, Safari, Chrome)

3. External debugger application
a. Weinre

BIAS ALERT!!
The code we’ll be using
● index.html
○ Gluing it all together

● script.js
○ Declaration of our DebuggerExamples object

● style.css
○ Nothing stylish :-)
Breaking the code - Statically
Static breakpoints using the debugger keyword
…
breakthru: function() {
// Queen
debugger;
…
}
…

Don’t do this!
Show me the code!
Breaking the code - Dynamically
Dynamic breakpoints

Best practice!
The pain of minified JavaScript
But my JavaScript is minified I can’t break in it?!

YES YOU CAN! :-)
The JavaScript GPS
● Navigate the code
● Get your position
● Breakpoints
○
○
○
○

Code
DOM
XHR
Event listener

?
The console.log command
● console.log('Most developers know this')
● console.log('And even ', this)
● console.log('What %s this %d?', 'about', 1)
● What is the output?!
Some more console commands
Command

What is the result?

inspect

>inspect(document.body)

$0

>$0

$_

>$_

copy

>copy($_)

dir

>dir($0)
Bonus question (given that jQuery is present):

clear

>clear()

>inspect($)
Want to learn more?
●

Some resources
○
○

http://www.paulirish.com/2011/a-re-introduction-to-the-chrome-developer-tools/

○

http://www.paulirish.com/2011/quick-color-manipulation-with-the-chrome-devtools/

○

http://www.randomthink.net/blog/2012/11/breakpoint-actions-in-javascript/

○

http://www.youtube.com/watch?v=nOEw9iiopwI

○
●

https://developers.google.com/chrome-developer-tools/docs/tips-and-tricks

http://www.youtube.com/watch?v=N8SS-rUEZPg&feature=youtu.be

And of course much of the same is possible in Firebug
○

http://lmgtfy.com/?q=Firebug+tips+and+tricks
Fishbone diagram
● Other name: Ishikawa diagram.
● Used for cause and effect analysis.
Fishbone diagram (2)
Fishbone diagram (3)
1.
2.
3.
4.

Collect all the effect of the errors.
With each effect, identify all the possible causes.
Analyze the causes, just to group and prioritize them.
Pick a cause from the list in prioritized order, make a
solution, then implement it.
5. If the error wasn’t been solved, back to step #4.
Pros for using the process?
● Help you to have an overview of the
problem.
● Easier to call for help, as well as better
collaboration.
● When you can’t discover the issue, you
My code broke, and I don’t know why...
know why.
Cons
Take times….
Questions?
Workshop
Problem #1

http://jsfiddle.net/jECLf/1/
Problem #2

http://jsfiddle.net/t45UM/
Problem #3

http://jsfiddle.net/Q7vhS/embedded/result/

http://jsfiddle.net/Q7vhS/

What is the problem, and how to fix?
Problem #4
var elements = [1,2,3,4,5,6,7,8,9];

I want to create a grid with 3 elements
in each row. This code relies on
jQuery, but there is something wrong,

$(elements).each(function(i, e) {

can you spot it?

var row;
if (i % 3 == 0) {
row = $('<div>').appendTo('body');
}
$('<span>' + e + '</span>').appendTo(row);
});
References
●

http://tobyho.com/2011/11/16/7-common-js-mistakes-or-confusions/

●

http://tobyho.com/2011/11/09/life-without-compiler/

●

http://tobyho.com/2011/11/11/js-object-inheritance/

●

http://net.tutsplus.com/tutorials/javascript-ajax/the-10-javascript-mistakes-youre-making/

●

http://nullprogram.com/blog/2012/11/19/

●

http://www.elijahmanor.com/2011/08/7-chrome-tips-developers-designers-may.html
Presentation made for “Javascript
Ho Chi Minh City” meetup group
You
●
●
●

can find us at:
http://meetup.com/JavaScript-Ho-Chi-Minh-City/
https://www.facebook.com/JavaScriptHCMC
https://plus.google.
com/communities/116105314977285194967
Thank you

More Related Content

Similar to Debugging JavaScript (by Thomas Bindzus, Founder, Vinagility & Thanh Loc Vo, CTO, Epsilon Mobile )

Are Automated Debugging Techniques Actually Helping Programmers
Are Automated Debugging Techniques Actually Helping ProgrammersAre Automated Debugging Techniques Actually Helping Programmers
Are Automated Debugging Techniques Actually Helping ProgrammersChris Parnin
 
Unleashing the power of Unit Testing - Franck Ninsabira.pdf
Unleashing the power of Unit Testing - Franck Ninsabira.pdfUnleashing the power of Unit Testing - Franck Ninsabira.pdf
Unleashing the power of Unit Testing - Franck Ninsabira.pdfGDG Bujumbura
 
Testing & should i do it
Testing & should i do itTesting & should i do it
Testing & should i do itMartin Sykora
 
Exception Handling: Designing Robust Software in Ruby (with presentation note)
Exception Handling: Designing Robust Software in Ruby (with presentation note)Exception Handling: Designing Robust Software in Ruby (with presentation note)
Exception Handling: Designing Robust Software in Ruby (with presentation note)Wen-Tien Chang
 
Works For Me! Characterizing Non-Reproducible Bug Reports
Works For Me! Characterizing Non-Reproducible Bug ReportsWorks For Me! Characterizing Non-Reproducible Bug Reports
Works For Me! Characterizing Non-Reproducible Bug ReportsSALT Lab @ UBC
 
VISUAL_BASIC_LECTURE_NOTE_A_Z_MADE_EASY.pdf
VISUAL_BASIC_LECTURE_NOTE_A_Z_MADE_EASY.pdfVISUAL_BASIC_LECTURE_NOTE_A_Z_MADE_EASY.pdf
VISUAL_BASIC_LECTURE_NOTE_A_Z_MADE_EASY.pdfNALANDACSCCENTRE
 
Introduction of Tools for providing rich user experience in debugger
Introduction of Tools for providing rich user experience in debuggerIntroduction of Tools for providing rich user experience in debugger
Introduction of Tools for providing rich user experience in debuggerNaoto Ono
 
Case Study of the Unexplained
Case Study of the UnexplainedCase Study of the Unexplained
Case Study of the Unexplainedshannomc
 
exception-handling-in-java.ppt
exception-handling-in-java.pptexception-handling-in-java.ppt
exception-handling-in-java.pptSanthiNivas
 
Stanislav Khorunzhyi, "Front-end it like a PRO"
Stanislav Khorunzhyi, "Front-end it like a PRO"Stanislav Khorunzhyi, "Front-end it like a PRO"
Stanislav Khorunzhyi, "Front-end it like a PRO"Sigma Software
 
Programming Fundamentals using C++
Programming Fundamentals using C++Programming Fundamentals using C++
Programming Fundamentals using C++ALI RAZA
 
Preparing for the WebGeek DevCup
Preparing for the WebGeek DevCupPreparing for the WebGeek DevCup
Preparing for the WebGeek DevCupbryanbibat
 

Similar to Debugging JavaScript (by Thomas Bindzus, Founder, Vinagility & Thanh Loc Vo, CTO, Epsilon Mobile ) (20)

Are Automated Debugging Techniques Actually Helping Programmers
Are Automated Debugging Techniques Actually Helping ProgrammersAre Automated Debugging Techniques Actually Helping Programmers
Are Automated Debugging Techniques Actually Helping Programmers
 
Spaghetti gate
Spaghetti gateSpaghetti gate
Spaghetti gate
 
Unleashing the power of Unit Testing - Franck Ninsabira.pdf
Unleashing the power of Unit Testing - Franck Ninsabira.pdfUnleashing the power of Unit Testing - Franck Ninsabira.pdf
Unleashing the power of Unit Testing - Franck Ninsabira.pdf
 
Testing & should i do it
Testing & should i do itTesting & should i do it
Testing & should i do it
 
Exception Handling: Designing Robust Software in Ruby (with presentation note)
Exception Handling: Designing Robust Software in Ruby (with presentation note)Exception Handling: Designing Robust Software in Ruby (with presentation note)
Exception Handling: Designing Robust Software in Ruby (with presentation note)
 
Works For Me! Characterizing Non-Reproducible Bug Reports
Works For Me! Characterizing Non-Reproducible Bug ReportsWorks For Me! Characterizing Non-Reproducible Bug Reports
Works For Me! Characterizing Non-Reproducible Bug Reports
 
Bug Hunting Safari
Bug Hunting SafariBug Hunting Safari
Bug Hunting Safari
 
VISUAL_BASIC_LECTURE_NOTE_A_Z_MADE_EASY.pdf
VISUAL_BASIC_LECTURE_NOTE_A_Z_MADE_EASY.pdfVISUAL_BASIC_LECTURE_NOTE_A_Z_MADE_EASY.pdf
VISUAL_BASIC_LECTURE_NOTE_A_Z_MADE_EASY.pdf
 
Debugging
DebuggingDebugging
Debugging
 
Introduction of Tools for providing rich user experience in debugger
Introduction of Tools for providing rich user experience in debuggerIntroduction of Tools for providing rich user experience in debugger
Introduction of Tools for providing rich user experience in debugger
 
Case Study of the Unexplained
Case Study of the UnexplainedCase Study of the Unexplained
Case Study of the Unexplained
 
exception-handling-in-java.ppt
exception-handling-in-java.pptexception-handling-in-java.ppt
exception-handling-in-java.ppt
 
Unit testing-patterns
Unit testing-patternsUnit testing-patterns
Unit testing-patterns
 
Stanislav Khorunzhyi, "Front-end it like a PRO"
Stanislav Khorunzhyi, "Front-end it like a PRO"Stanislav Khorunzhyi, "Front-end it like a PRO"
Stanislav Khorunzhyi, "Front-end it like a PRO"
 
Debugging
DebuggingDebugging
Debugging
 
Js unit testing
Js unit testingJs unit testing
Js unit testing
 
Debugging
DebuggingDebugging
Debugging
 
It Works On Dev
It Works On DevIt Works On Dev
It Works On Dev
 
Programming Fundamentals using C++
Programming Fundamentals using C++Programming Fundamentals using C++
Programming Fundamentals using C++
 
Preparing for the WebGeek DevCup
Preparing for the WebGeek DevCupPreparing for the WebGeek DevCup
Preparing for the WebGeek DevCup
 

More from JavaScript Meetup HCMC

Writing testable js [by Ted Piotrowski]
Writing testable js [by Ted Piotrowski]Writing testable js [by Ted Piotrowski]
Writing testable js [by Ted Piotrowski]JavaScript Meetup HCMC
 
Building workflow in Javascript: Build the awesome with Gulp.
Building workflow in Javascript: Build the awesome with Gulp.   Building workflow in Javascript: Build the awesome with Gulp.
Building workflow in Javascript: Build the awesome with Gulp. JavaScript Meetup HCMC
 
[Js hcm] Java script- Testing the awesome
[Js hcm] Java script- Testing the awesome[Js hcm] Java script- Testing the awesome
[Js hcm] Java script- Testing the awesomeJavaScript Meetup HCMC
 
3D Web Programming [Thanh Loc Vo , CTO Epsilon Mobile ]
3D Web Programming [Thanh Loc Vo , CTO Epsilon Mobile ]3D Web Programming [Thanh Loc Vo , CTO Epsilon Mobile ]
3D Web Programming [Thanh Loc Vo , CTO Epsilon Mobile ]JavaScript Meetup HCMC
 
Khanh-Nguyen - Gearman - distributed process solution
Khanh-Nguyen - Gearman - distributed process solutionKhanh-Nguyen - Gearman - distributed process solution
Khanh-Nguyen - Gearman - distributed process solutionJavaScript Meetup HCMC
 
Nicolas-Embleton - Deploying node.js with forever and nginx
Nicolas-Embleton  - Deploying node.js with forever and nginxNicolas-Embleton  - Deploying node.js with forever and nginx
Nicolas-Embleton - Deploying node.js with forever and nginxJavaScript Meetup HCMC
 

More from JavaScript Meetup HCMC (8)

Writing testable js [by Ted Piotrowski]
Writing testable js [by Ted Piotrowski]Writing testable js [by Ted Piotrowski]
Writing testable js [by Ted Piotrowski]
 
Building workflow in Javascript: Build the awesome with Gulp.
Building workflow in Javascript: Build the awesome with Gulp.   Building workflow in Javascript: Build the awesome with Gulp.
Building workflow in Javascript: Build the awesome with Gulp.
 
[Js hcm] Java script- Testing the awesome
[Js hcm] Java script- Testing the awesome[Js hcm] Java script- Testing the awesome
[Js hcm] Java script- Testing the awesome
 
Knockout js (Dennis Haney)
Knockout js (Dennis Haney)Knockout js (Dennis Haney)
Knockout js (Dennis Haney)
 
3D Web Programming [Thanh Loc Vo , CTO Epsilon Mobile ]
3D Web Programming [Thanh Loc Vo , CTO Epsilon Mobile ]3D Web Programming [Thanh Loc Vo , CTO Epsilon Mobile ]
3D Web Programming [Thanh Loc Vo , CTO Epsilon Mobile ]
 
Nicolas Embleton, Advanced Angular JS
Nicolas Embleton, Advanced Angular JSNicolas Embleton, Advanced Angular JS
Nicolas Embleton, Advanced Angular JS
 
Khanh-Nguyen - Gearman - distributed process solution
Khanh-Nguyen - Gearman - distributed process solutionKhanh-Nguyen - Gearman - distributed process solution
Khanh-Nguyen - Gearman - distributed process solution
 
Nicolas-Embleton - Deploying node.js with forever and nginx
Nicolas-Embleton  - Deploying node.js with forever and nginxNicolas-Embleton  - Deploying node.js with forever and nginx
Nicolas-Embleton - Deploying node.js with forever and nginx
 

Recently uploaded

Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsAndrey Dotsenko
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 

Recently uploaded (20)

Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 

Debugging JavaScript (by Thomas Bindzus, Founder, Vinagility & Thanh Loc Vo, CTO, Epsilon Mobile )