SlideShare a Scribd company logo
Debugging Javascript
DEBUGGING JAVASCRIPT 
FROM 0 TO HEISENBERG 
Chris Morrow 
Senior UI Developer
WALTER WHITE
HEISENBERG
THE PLAN 
JAVASCRIPT BEST PRACTICES (throughout) 
BREAKPOINTS 
WATCHES 
USING THE CONSOLE 
CALL STACK 
CUSTOM TOOLS / UNIT TESTING
TOO MANY COOKS IN 
THE KITCHEN?
BEST PRACTICES 
AVOID GLOBAL VARIABLES 
<script> 
var now = new Date(); 
/* more code goes here */ 
function doSomething(){ 
alert('the time is ' + now); 
} 
</script> 
/* code below can overwrite "now" var */ 
<script src="js/dateLibrary.js"></script>
PROTECT YOUR VARIABLES WITH SCOPE 
<script> 
(function(){ // closure function 
var now = new Date(); 
/* more code goes here */ 
function doSomething(){ 
alert('the time is ' + now); 
} 
})(); 
</script> 
/* code below CAN'T change "now" var */
Debugging Javascript
WHY DO PEOPLE HATE 
DEBUGGING JS? 
VARIABLES ARE GLOBAL IN SCOPE 
NO REQUIRED STRONG TYPING 
CROSS BROWSER COMPATIBILITY (IE!!!) 
NO CLASSES
DEBUGGING GOT YOU 
STRESSED?
BREAKPOINTS 
NAVIGATING CODE 
STANDARD 
CONDITIONAL
BREAKPOINTS 
Continue: continues code execution until we encounter 
another breakpoint 
Step Over: step through code line-by-line to get insights into 
how each line affects the variables being updated. Should 
your code call another function, the debugger won't jump into its 
code, instead stepping over so that the focus remains on the 
current function (scope). 
Step Into: like Step over, however clicking Step into at the 
function call will cause the debugger to move its execution 
to the first line in the functions definition. 
Step Out: having stepped into a function, clicking this will 
cause the remainder of the function definition to be run and 
the debugger will move its execution to the parent function
BEST PRACTICES
WATCHES
ADDING A WATCH: MULTIPLE WAYS 
k Sources: select then right-click 
k Click "+" on Watch Expressions panel 
k Right-click inside Watch Expressions panel
SCOPE VARIABLES 
k Like watches, but are only shown in scope
AND NOW A QUICK MESSAGE FROM OUR 
SPONSOR...
Debugging Javascript
USING THE CONSOLE 
console.log() 
console.assert( expression, object ) 
console.table() 
Multiline Commands 
Snippets 
Live Editing
BEST PRACTICES 
DO NOT MINIFY CODE IN DEVELOPMENT
Debugging Javascript
CALL STACK 
BOTTOMS UP
CRAPPY CODE
CLEAN UP YOUR CODE
DEBUGGING TOOLS 
ROLL YOUR OWN
PRE-DEBUGGING TOOLS 
JSHint / JSLint 
JsHint is more lenient than JSLint.
NOT HAPPY WITH 
JSHINT?
CUSTO MIZE I T WITH 
.jshintrc
UNIT TESTING 
QUnit: http://qunitjs.com/ 
Mocha: http://visionmedia.github.io/mocha/ 
Jasmine: http://jasmine.github.io/
REMOTE TESTING 
Android - (Chrome Dev Tools) 
https://developer.chrome.com/devtools 
iOS - (Safari Dev Tools) 
https://developer.apple.com/safari/tools/ 
Browser Stack: $39.99/month and up 
http://www.browserstack.com/ 
Adobe Edge Inspect: $9.99/month 
https://creative.adobe.com/products/inspect
RESOURCES / QUESTIONS? 
Chrome Dev Tools: 
https://developer.chrome.com/devtools 
Chrome Dev Tools: Tips & Tricks 
https://developer.chrome.com/devtools/docs/tips-and-tricks 
jQuery Learning Center: 
http://learn.jquery.com/javascript-101/ 
Design Patterns: 
http://addyosmani.com/resources/essentialjsdesignpatterns/book/ 
Douglas Crockford: Javascript the Good Parts 
http://javascript.crockford.com/
Debugging Javascript

More Related Content

What's hot (20)

PDF
Java script tutorial
Doeun KOCH
 
PPTX
Intro to TDD and BDD
Jason Noble
 
PDF
Angular - Chapter 2 - TypeScript Programming
WebStackAcademy
 
PPTX
Introduction to JavaScript
Marlon Jamera
 
PPTX
Introduction To JavaScript
Reema
 
PDF
Intro to React
SheilaJimenezMorejon
 
PDF
Javascript
Vibhor Grover
 
PPTX
Javascript session 01 - Introduction to Javascript
Livingston Samuel
 
PDF
JavaScript - Chapter 7 - Advanced Functions
WebStackAcademy
 
PDF
Test Driven Development with JavaFX
Hendrik Ebbers
 
PPTX
Javascript
Sun Technlogies
 
PPTX
Jsp
JayaKamal
 
PPT
2310 b 03
Krazy Koder
 
DOCX
Unit 2.4
Abhishek Kesharwani
 
PPT
Ajax
Muhammad Umar
 
PDF
Сергей Больщиков "Protractor Tips & Tricks"
Fwdays
 
PPT
2310 b 13
Krazy Koder
 
PDF
JavaScript 101
ygv2000
 
PPTX
Asp.net mvc
erdemergin
 
Java script tutorial
Doeun KOCH
 
Intro to TDD and BDD
Jason Noble
 
Angular - Chapter 2 - TypeScript Programming
WebStackAcademy
 
Introduction to JavaScript
Marlon Jamera
 
Introduction To JavaScript
Reema
 
Intro to React
SheilaJimenezMorejon
 
Javascript
Vibhor Grover
 
Javascript session 01 - Introduction to Javascript
Livingston Samuel
 
JavaScript - Chapter 7 - Advanced Functions
WebStackAcademy
 
Test Driven Development with JavaFX
Hendrik Ebbers
 
Javascript
Sun Technlogies
 
2310 b 03
Krazy Koder
 
Сергей Больщиков "Protractor Tips & Tricks"
Fwdays
 
2310 b 13
Krazy Koder
 
JavaScript 101
ygv2000
 
Asp.net mvc
erdemergin
 

Viewers also liked (7)

PDF
Debugging JavaScript (by Thomas Bindzus, Founder, Vinagility & Thanh Loc Vo, ...
JavaScript Meetup HCMC
 
PDF
FITC - Here Be Dragons: Advanced JavaScript Debugging
Rami Sayar
 
PPTX
A few good JavaScript development tools
Simon Kim
 
PDF
JavaScript tracing, debugging, profiling made simple with spy-js
Artem Govorov
 
PDF
Debugging tools in web browsers
Sarah Dutkiewicz
 
KEY
Tools and Techniques for Faster Development
jtaby
 
PDF
Finding and debugging memory leaks in JavaScript with Chrome DevTools
Gonzalo Ruiz de Villa
 
Debugging JavaScript (by Thomas Bindzus, Founder, Vinagility & Thanh Loc Vo, ...
JavaScript Meetup HCMC
 
FITC - Here Be Dragons: Advanced JavaScript Debugging
Rami Sayar
 
A few good JavaScript development tools
Simon Kim
 
JavaScript tracing, debugging, profiling made simple with spy-js
Artem Govorov
 
Debugging tools in web browsers
Sarah Dutkiewicz
 
Tools and Techniques for Faster Development
jtaby
 
Finding and debugging memory leaks in JavaScript with Chrome DevTools
Gonzalo Ruiz de Villa
 
Ad

Similar to Debugging Javascript (20)

PDF
Debugging Javascript - 0 to Heisenberg
Chris Morrow
 
PDF
Debugging with VS2019
Mirco Vanini
 
PDF
20150812 4시간만에 따라해보는 windows 10 앱 개발
영욱 김
 
PDF
Release with confidence
John Congdon
 
DOCX
Debugger & Profiler in NetBeans
Huu Bang Le Phan
 
PDF
Tom Germeau: Mobile Apps: Finding the balance between performance and flexibi...
Chartbeat
 
PDF
Cucumber meets iPhone
Erin Dees
 
PDF
Debugging an Angular App
Laurent Duveau
 
KEY
Mobile optimization
purplecabbage
 
PDF
Behavioural Driven Development in Zf2
David Contavalli
 
PPT
Sanjeev ghai 12
Praveen kumar
 
PPTX
Claim Academy Intro to Programming
Alex Pearson
 
ODP
Plug yourself in and your app will never be the same (1 hr edition)
Mikkel Flindt Heisterberg
 
PPTX
wp-UNIT_III.pptx
GANDHAMKUMAR2
 
PDF
30 Tools for Modern .NET Web Development in 60 Minutes (Jonathan Tower)
ITCamp
 
PDF
Real world Webapp
Things Lab
 
PPTX
Code instrumentation
Mennan Tekbir
 
PPT
Code Quality Practice and Tools
Bob Paulin
 
DOCX
ID E's features
wajahat Gul
 
PDF
Headless Js Testing
Brian Moschel
 
Debugging Javascript - 0 to Heisenberg
Chris Morrow
 
Debugging with VS2019
Mirco Vanini
 
20150812 4시간만에 따라해보는 windows 10 앱 개발
영욱 김
 
Release with confidence
John Congdon
 
Debugger & Profiler in NetBeans
Huu Bang Le Phan
 
Tom Germeau: Mobile Apps: Finding the balance between performance and flexibi...
Chartbeat
 
Cucumber meets iPhone
Erin Dees
 
Debugging an Angular App
Laurent Duveau
 
Mobile optimization
purplecabbage
 
Behavioural Driven Development in Zf2
David Contavalli
 
Sanjeev ghai 12
Praveen kumar
 
Claim Academy Intro to Programming
Alex Pearson
 
Plug yourself in and your app will never be the same (1 hr edition)
Mikkel Flindt Heisterberg
 
wp-UNIT_III.pptx
GANDHAMKUMAR2
 
30 Tools for Modern .NET Web Development in 60 Minutes (Jonathan Tower)
ITCamp
 
Real world Webapp
Things Lab
 
Code instrumentation
Mennan Tekbir
 
Code Quality Practice and Tools
Bob Paulin
 
ID E's features
wajahat Gul
 
Headless Js Testing
Brian Moschel
 
Ad

More from SolTech, Inc. (8)

PDF
Responsive Web Design using the Foundation 5 CSS Framework
SolTech, Inc.
 
PPTX
How to Rock your Phone Interview: 4 Easy Steps
SolTech, Inc.
 
PPTX
Empowering Your Job Search: 10 Tips
SolTech, Inc.
 
PDF
Responsive Web Design using ZURB Foundation
SolTech, Inc.
 
PPTX
Introduction to Dependency Injection
SolTech, Inc.
 
PPTX
Getting started with Xamarin forms
SolTech, Inc.
 
PPTX
Intro to AngularJs
SolTech, Inc.
 
PDF
SolTech's The Constantly Connected Customer
SolTech, Inc.
 
Responsive Web Design using the Foundation 5 CSS Framework
SolTech, Inc.
 
How to Rock your Phone Interview: 4 Easy Steps
SolTech, Inc.
 
Empowering Your Job Search: 10 Tips
SolTech, Inc.
 
Responsive Web Design using ZURB Foundation
SolTech, Inc.
 
Introduction to Dependency Injection
SolTech, Inc.
 
Getting started with Xamarin forms
SolTech, Inc.
 
Intro to AngularJs
SolTech, Inc.
 
SolTech's The Constantly Connected Customer
SolTech, Inc.
 

Recently uploaded (20)

PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PPTX
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
PPTX
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PDF
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PDF
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
PPTX
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
PDF
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
PPTX
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PDF
Driver Easy Pro 6.1.1 Crack Licensce key 2025 FREE
utfefguu
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
PPTX
Coefficient of Variance in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
PDF
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
Driver Easy Pro 6.1.1 Crack Licensce key 2025 FREE
utfefguu
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
Coefficient of Variance in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 

Debugging Javascript

  • 2. DEBUGGING JAVASCRIPT FROM 0 TO HEISENBERG Chris Morrow Senior UI Developer
  • 5. THE PLAN JAVASCRIPT BEST PRACTICES (throughout) BREAKPOINTS WATCHES USING THE CONSOLE CALL STACK CUSTOM TOOLS / UNIT TESTING
  • 6. TOO MANY COOKS IN THE KITCHEN?
  • 7. BEST PRACTICES AVOID GLOBAL VARIABLES <script> var now = new Date(); /* more code goes here */ function doSomething(){ alert('the time is ' + now); } </script> /* code below can overwrite "now" var */ <script src="js/dateLibrary.js"></script>
  • 8. PROTECT YOUR VARIABLES WITH SCOPE <script> (function(){ // closure function var now = new Date(); /* more code goes here */ function doSomething(){ alert('the time is ' + now); } })(); </script> /* code below CAN'T change "now" var */
  • 10. WHY DO PEOPLE HATE DEBUGGING JS? VARIABLES ARE GLOBAL IN SCOPE NO REQUIRED STRONG TYPING CROSS BROWSER COMPATIBILITY (IE!!!) NO CLASSES
  • 11. DEBUGGING GOT YOU STRESSED?
  • 12. BREAKPOINTS NAVIGATING CODE STANDARD CONDITIONAL
  • 13. BREAKPOINTS Continue: continues code execution until we encounter another breakpoint Step Over: step through code line-by-line to get insights into how each line affects the variables being updated. Should your code call another function, the debugger won't jump into its code, instead stepping over so that the focus remains on the current function (scope). Step Into: like Step over, however clicking Step into at the function call will cause the debugger to move its execution to the first line in the functions definition. Step Out: having stepped into a function, clicking this will cause the remainder of the function definition to be run and the debugger will move its execution to the parent function
  • 16. ADDING A WATCH: MULTIPLE WAYS k Sources: select then right-click k Click "+" on Watch Expressions panel k Right-click inside Watch Expressions panel
  • 17. SCOPE VARIABLES k Like watches, but are only shown in scope
  • 18. AND NOW A QUICK MESSAGE FROM OUR SPONSOR...
  • 20. USING THE CONSOLE console.log() console.assert( expression, object ) console.table() Multiline Commands Snippets Live Editing
  • 21. BEST PRACTICES DO NOT MINIFY CODE IN DEVELOPMENT
  • 27. PRE-DEBUGGING TOOLS JSHint / JSLint JsHint is more lenient than JSLint.
  • 28. NOT HAPPY WITH JSHINT?
  • 29. CUSTO MIZE I T WITH .jshintrc
  • 30. UNIT TESTING QUnit: http://qunitjs.com/ Mocha: http://visionmedia.github.io/mocha/ Jasmine: http://jasmine.github.io/
  • 31. REMOTE TESTING Android - (Chrome Dev Tools) https://developer.chrome.com/devtools iOS - (Safari Dev Tools) https://developer.apple.com/safari/tools/ Browser Stack: $39.99/month and up http://www.browserstack.com/ Adobe Edge Inspect: $9.99/month https://creative.adobe.com/products/inspect
  • 32. RESOURCES / QUESTIONS? Chrome Dev Tools: https://developer.chrome.com/devtools Chrome Dev Tools: Tips & Tricks https://developer.chrome.com/devtools/docs/tips-and-tricks jQuery Learning Center: http://learn.jquery.com/javascript-101/ Design Patterns: http://addyosmani.com/resources/essentialjsdesignpatterns/book/ Douglas Crockford: Javascript the Good Parts http://javascript.crockford.com/