SlideShare a Scribd company logo
1 of 33
Download to read offline
DEBUGGING JAVASCRIPT 
0 TO HEISENBERG 
Chris Morrow 
Senior UI Developer 
Video screencast: http://youtu.be/-q1z8BPFItw
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 */
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...
USING THE CONSOLE 
console.log() 
console.assert( expression, object ) 
console.table() 
Multiline Commands 
Snippets 
Live Editing
BEST PRACTICES 
DO NOT MINIFY CODE IN DEVELOPMENT
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 
ADOBE EDGE 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 - 0 to Heisenberg

More Related Content

What's hot

Getting Started with Tizen TV Web Apps
Getting Started with Tizen TV Web AppsGetting Started with Tizen TV Web Apps
Getting Started with Tizen TV Web AppsRyo Jin
 
Using Prometheus to monitor your build pipelines
Using Prometheus to monitor your build pipelinesUsing Prometheus to monitor your build pipelines
Using Prometheus to monitor your build pipelinesLander Van den Bulcke
 
Openstack Vagrant plugin overview
Openstack Vagrant plugin overviewOpenstack Vagrant plugin overview
Openstack Vagrant plugin overviewMarton Kiss
 
Enterprising JavaFX
Enterprising JavaFXEnterprising JavaFX
Enterprising JavaFXRichard Bair
 
Droidcon ES '16 - How to fail going offline
Droidcon ES '16 - How to fail going offlineDroidcon ES '16 - How to fail going offline
Droidcon ES '16 - How to fail going offlineJavier de Pedro López
 
Site Testing with CasperJS
Site Testing with CasperJSSite Testing with CasperJS
Site Testing with CasperJSJoseph Scott
 
Phone gap android plugins
Phone gap android pluginsPhone gap android plugins
Phone gap android pluginsSimon MacDonald
 
Level up your front-end skills- going beyond cold fusion’s ui tags
Level up your front-end skills- going beyond cold fusion’s ui tagsLevel up your front-end skills- going beyond cold fusion’s ui tags
Level up your front-end skills- going beyond cold fusion’s ui tagsColdFusionConference
 
Using Composer with WordPress
Using Composer with WordPressUsing Composer with WordPress
Using Composer with WordPressMicah Wood
 
IS YOUR WIDGET FAST? FIVE BEST PRACTICES TO FASTER EMBEDDABLE CONTENT
IS YOUR WIDGET FAST? FIVE BEST PRACTICES TO FASTER EMBEDDABLE CONTENTIS YOUR WIDGET FAST? FIVE BEST PRACTICES TO FASTER EMBEDDABLE CONTENT
IS YOUR WIDGET FAST? FIVE BEST PRACTICES TO FASTER EMBEDDABLE CONTENTIsmail Elshareef
 
Superfast Automated Web Testing with CasperJS & PhantomJS
Superfast Automated Web Testing with CasperJS & PhantomJS Superfast Automated Web Testing with CasperJS & PhantomJS
Superfast Automated Web Testing with CasperJS & PhantomJS Hervé Vũ Roussel
 
End to-end testing from rookie to pro
End to-end testing  from rookie to proEnd to-end testing  from rookie to pro
End to-end testing from rookie to proDomenico Gemoli
 
CasperJS and PhantomJS for Automated Testing
CasperJS and PhantomJS for Automated TestingCasperJS and PhantomJS for Automated Testing
CasperJS and PhantomJS for Automated TestingX-Team
 
Introduction to phone gap
Introduction to phone gapIntroduction to phone gap
Introduction to phone gapDanet Krueng
 
RxSwift for Beginners - how to avoid a headache of reactive programming
RxSwift for Beginners - how to avoid a headache of reactive programmingRxSwift for Beginners - how to avoid a headache of reactive programming
RxSwift for Beginners - how to avoid a headache of reactive programmingMaciej Kołek
 

What's hot (18)

Getting Started with Tizen TV Web Apps
Getting Started with Tizen TV Web AppsGetting Started with Tizen TV Web Apps
Getting Started with Tizen TV Web Apps
 
Auto Build
Auto BuildAuto Build
Auto Build
 
Using Prometheus to monitor your build pipelines
Using Prometheus to monitor your build pipelinesUsing Prometheus to monitor your build pipelines
Using Prometheus to monitor your build pipelines
 
Openstack Vagrant plugin overview
Openstack Vagrant plugin overviewOpenstack Vagrant plugin overview
Openstack Vagrant plugin overview
 
Enterprising JavaFX
Enterprising JavaFXEnterprising JavaFX
Enterprising JavaFX
 
Droidcon ES '16 - How to fail going offline
Droidcon ES '16 - How to fail going offlineDroidcon ES '16 - How to fail going offline
Droidcon ES '16 - How to fail going offline
 
Site Testing with CasperJS
Site Testing with CasperJSSite Testing with CasperJS
Site Testing with CasperJS
 
Phone gap android plugins
Phone gap android pluginsPhone gap android plugins
Phone gap android plugins
 
Level up your front-end skills- going beyond cold fusion’s ui tags
Level up your front-end skills- going beyond cold fusion’s ui tagsLevel up your front-end skills- going beyond cold fusion’s ui tags
Level up your front-end skills- going beyond cold fusion’s ui tags
 
Using Composer with WordPress
Using Composer with WordPressUsing Composer with WordPress
Using Composer with WordPress
 
IS YOUR WIDGET FAST? FIVE BEST PRACTICES TO FASTER EMBEDDABLE CONTENT
IS YOUR WIDGET FAST? FIVE BEST PRACTICES TO FASTER EMBEDDABLE CONTENTIS YOUR WIDGET FAST? FIVE BEST PRACTICES TO FASTER EMBEDDABLE CONTENT
IS YOUR WIDGET FAST? FIVE BEST PRACTICES TO FASTER EMBEDDABLE CONTENT
 
Superfast Automated Web Testing with CasperJS & PhantomJS
Superfast Automated Web Testing with CasperJS & PhantomJS Superfast Automated Web Testing with CasperJS & PhantomJS
Superfast Automated Web Testing with CasperJS & PhantomJS
 
End to-end testing from rookie to pro
End to-end testing  from rookie to proEnd to-end testing  from rookie to pro
End to-end testing from rookie to pro
 
Flask
FlaskFlask
Flask
 
CasperJS and PhantomJS for Automated Testing
CasperJS and PhantomJS for Automated TestingCasperJS and PhantomJS for Automated Testing
CasperJS and PhantomJS for Automated Testing
 
Vagrant and chef
Vagrant and chefVagrant and chef
Vagrant and chef
 
Introduction to phone gap
Introduction to phone gapIntroduction to phone gap
Introduction to phone gap
 
RxSwift for Beginners - how to avoid a headache of reactive programming
RxSwift for Beginners - how to avoid a headache of reactive programmingRxSwift for Beginners - how to avoid a headache of reactive programming
RxSwift for Beginners - how to avoid a headache of reactive programming
 

Viewers also liked

Missing vin (1)
Missing vin (1)Missing vin (1)
Missing vin (1)Osopher
 
GeoMapFish, the Open Source WebGIS
GeoMapFish, the Open Source WebGISGeoMapFish, the Open Source WebGIS
GeoMapFish, the Open Source WebGISCamptocamp
 
A Measurement Study of 4chan’s Politically Incorrect Forum and Its Effects on...
A Measurement Study of 4chan’s Politically Incorrect Forum and Its Effects on...A Measurement Study of 4chan’s Politically Incorrect Forum and Its Effects on...
A Measurement Study of 4chan’s Politically Incorrect Forum and Its Effects on...Emiliano De Cristofaro
 
Moving beyond Blackboard: The VLE journey at Dundee
Moving beyond Blackboard: The VLE journey at DundeeMoving beyond Blackboard: The VLE journey at Dundee
Moving beyond Blackboard: The VLE journey at DundeeNatalie Lafferty
 
announcements- Friday March 31, 2017
announcements- Friday March 31, 2017announcements- Friday March 31, 2017
announcements- Friday March 31, 2017Ken Stayner
 
All the basics that interior designers work on
All the basics that interior designers work onAll the basics that interior designers work on
All the basics that interior designers work onNitidodesign
 
LCMS-MS Method for Evaluation of PPCPs in Environmental Water
LCMS-MS Method for Evaluation of PPCPs in Environmental WaterLCMS-MS Method for Evaluation of PPCPs in Environmental Water
LCMS-MS Method for Evaluation of PPCPs in Environmental WaterShimadzu Scientific Instruments
 

Viewers also liked (14)

MVS: An angular MVC
MVS: An angular MVCMVS: An angular MVC
MVS: An angular MVC
 
C All 2008 7 22
C All 2008 7 22C All 2008 7 22
C All 2008 7 22
 
Csfpt ppcr mars 2017
Csfpt ppcr mars 2017Csfpt ppcr mars 2017
Csfpt ppcr mars 2017
 
You are valuable
You are valuableYou are valuable
You are valuable
 
Missing vin (1)
Missing vin (1)Missing vin (1)
Missing vin (1)
 
GeoMapFish, the Open Source WebGIS
GeoMapFish, the Open Source WebGISGeoMapFish, the Open Source WebGIS
GeoMapFish, the Open Source WebGIS
 
A Measurement Study of 4chan’s Politically Incorrect Forum and Its Effects on...
A Measurement Study of 4chan’s Politically Incorrect Forum and Its Effects on...A Measurement Study of 4chan’s Politically Incorrect Forum and Its Effects on...
A Measurement Study of 4chan’s Politically Incorrect Forum and Its Effects on...
 
Dossier Pedagogique Festival Electrochoc 12
Dossier Pedagogique Festival Electrochoc 12 Dossier Pedagogique Festival Electrochoc 12
Dossier Pedagogique Festival Electrochoc 12
 
Moving beyond Blackboard: The VLE journey at Dundee
Moving beyond Blackboard: The VLE journey at DundeeMoving beyond Blackboard: The VLE journey at Dundee
Moving beyond Blackboard: The VLE journey at Dundee
 
Maar wat is Sosiale Media?
Maar wat is Sosiale Media?Maar wat is Sosiale Media?
Maar wat is Sosiale Media?
 
announcements- Friday March 31, 2017
announcements- Friday March 31, 2017announcements- Friday March 31, 2017
announcements- Friday March 31, 2017
 
S3 a1 liberatom_leslieg
S3 a1 liberatom_lesliegS3 a1 liberatom_leslieg
S3 a1 liberatom_leslieg
 
All the basics that interior designers work on
All the basics that interior designers work onAll the basics that interior designers work on
All the basics that interior designers work on
 
LCMS-MS Method for Evaluation of PPCPs in Environmental Water
LCMS-MS Method for Evaluation of PPCPs in Environmental WaterLCMS-MS Method for Evaluation of PPCPs in Environmental Water
LCMS-MS Method for Evaluation of PPCPs in Environmental Water
 

Similar to Debugging Javascript - 0 to Heisenberg

Debugging Javascript
Debugging JavascriptDebugging Javascript
Debugging JavascriptSolTech, Inc.
 
Debugger & Profiler in NetBeans
Debugger & Profiler in NetBeansDebugger & Profiler in NetBeans
Debugger & Profiler in NetBeansHuu Bang Le Phan
 
Cucumber meets iPhone
Cucumber meets iPhoneCucumber meets iPhone
Cucumber meets iPhoneErin Dees
 
Release with confidence
Release with confidenceRelease with confidence
Release with confidenceJohn Congdon
 
Plug yourself in and your app will never be the same (1 hr edition)
Plug yourself in and your app will never be the same (1 hr edition)Plug yourself in and your app will never be the same (1 hr edition)
Plug yourself in and your app will never be the same (1 hr edition)Mikkel Flindt Heisterberg
 
Tom Germeau: Mobile Apps: Finding the balance between performance and flexibi...
Tom Germeau: Mobile Apps: Finding the balance between performance and flexibi...Tom Germeau: Mobile Apps: Finding the balance between performance and flexibi...
Tom Germeau: Mobile Apps: Finding the balance between performance and flexibi...Chartbeat
 
413450-rc218-cdw-jenkins-workflow
413450-rc218-cdw-jenkins-workflow413450-rc218-cdw-jenkins-workflow
413450-rc218-cdw-jenkins-workflowAndy Pemberton
 
CoffeeScript, An Introduction for Nodejs developers
CoffeeScript, An Introduction for Nodejs developersCoffeeScript, An Introduction for Nodejs developers
CoffeeScript, An Introduction for Nodejs developersMehdi Valikhani
 
Continous Delivering a PHP application
Continous Delivering a PHP applicationContinous Delivering a PHP application
Continous Delivering a PHP applicationJavier López
 
Joomla! Day Chicago 2011 Presentation - Steven Pignataro
Joomla! Day Chicago 2011 Presentation - Steven PignataroJoomla! Day Chicago 2011 Presentation - Steven Pignataro
Joomla! Day Chicago 2011 Presentation - Steven PignataroSteven Pignataro
 
React Native in Production
React Native in ProductionReact Native in Production
React Native in ProductionSeokjun Kim
 
Two Years, Zero servers: Lessons learned from running a startup 100% on Serve...
Two Years, Zero servers: Lessons learned from running a startup 100% on Serve...Two Years, Zero servers: Lessons learned from running a startup 100% on Serve...
Two Years, Zero servers: Lessons learned from running a startup 100% on Serve...Cloud Native Day Tel Aviv
 
Real world Webapp
Real world WebappReal world Webapp
Real world WebappThings Lab
 
2011 py con
2011 py con2011 py con
2011 py conEing Ong
 
Debugging with VS2019
Debugging with VS2019Debugging with VS2019
Debugging with VS2019Mirco Vanini
 
20150812 4시간만에 따라해보는 windows 10 앱 개발
20150812  4시간만에 따라해보는 windows 10 앱 개발20150812  4시간만에 따라해보는 windows 10 앱 개발
20150812 4시간만에 따라해보는 windows 10 앱 개발영욱 김
 
Behavioural Driven Development in Zf2
Behavioural Driven Development in Zf2Behavioural Driven Development in Zf2
Behavioural Driven Development in Zf2David Contavalli
 
Ultimate Productivity Tools
Ultimate Productivity ToolsUltimate Productivity Tools
Ultimate Productivity ToolsAmal Dev
 

Similar to Debugging Javascript - 0 to Heisenberg (20)

Debugging Javascript
Debugging JavascriptDebugging Javascript
Debugging Javascript
 
Debugger & Profiler in NetBeans
Debugger & Profiler in NetBeansDebugger & Profiler in NetBeans
Debugger & Profiler in NetBeans
 
Cucumber meets iPhone
Cucumber meets iPhoneCucumber meets iPhone
Cucumber meets iPhone
 
Release with confidence
Release with confidenceRelease with confidence
Release with confidence
 
Plug yourself in and your app will never be the same (1 hr edition)
Plug yourself in and your app will never be the same (1 hr edition)Plug yourself in and your app will never be the same (1 hr edition)
Plug yourself in and your app will never be the same (1 hr edition)
 
Tom Germeau: Mobile Apps: Finding the balance between performance and flexibi...
Tom Germeau: Mobile Apps: Finding the balance between performance and flexibi...Tom Germeau: Mobile Apps: Finding the balance between performance and flexibi...
Tom Germeau: Mobile Apps: Finding the balance between performance and flexibi...
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
413450-rc218-cdw-jenkins-workflow
413450-rc218-cdw-jenkins-workflow413450-rc218-cdw-jenkins-workflow
413450-rc218-cdw-jenkins-workflow
 
CoffeeScript, An Introduction for Nodejs developers
CoffeeScript, An Introduction for Nodejs developersCoffeeScript, An Introduction for Nodejs developers
CoffeeScript, An Introduction for Nodejs developers
 
ID E's features
ID E's featuresID E's features
ID E's features
 
Continous Delivering a PHP application
Continous Delivering a PHP applicationContinous Delivering a PHP application
Continous Delivering a PHP application
 
Joomla! Day Chicago 2011 Presentation - Steven Pignataro
Joomla! Day Chicago 2011 Presentation - Steven PignataroJoomla! Day Chicago 2011 Presentation - Steven Pignataro
Joomla! Day Chicago 2011 Presentation - Steven Pignataro
 
React Native in Production
React Native in ProductionReact Native in Production
React Native in Production
 
Two Years, Zero servers: Lessons learned from running a startup 100% on Serve...
Two Years, Zero servers: Lessons learned from running a startup 100% on Serve...Two Years, Zero servers: Lessons learned from running a startup 100% on Serve...
Two Years, Zero servers: Lessons learned from running a startup 100% on Serve...
 
Real world Webapp
Real world WebappReal world Webapp
Real world Webapp
 
2011 py con
2011 py con2011 py con
2011 py con
 
Debugging with VS2019
Debugging with VS2019Debugging with VS2019
Debugging with VS2019
 
20150812 4시간만에 따라해보는 windows 10 앱 개발
20150812  4시간만에 따라해보는 windows 10 앱 개발20150812  4시간만에 따라해보는 windows 10 앱 개발
20150812 4시간만에 따라해보는 windows 10 앱 개발
 
Behavioural Driven Development in Zf2
Behavioural Driven Development in Zf2Behavioural Driven Development in Zf2
Behavioural Driven Development in Zf2
 
Ultimate Productivity Tools
Ultimate Productivity ToolsUltimate Productivity Tools
Ultimate Productivity Tools
 

Recently uploaded

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
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
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 pragmaticscarlostorres15106
 
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
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 

Recently uploaded (20)

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
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
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
 
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...
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at 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
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 

Debugging Javascript - 0 to Heisenberg

  • 1.
  • 2. DEBUGGING JAVASCRIPT 0 TO HEISENBERG Chris Morrow Senior UI Developer Video screencast: http://youtu.be/-q1z8BPFItw
  • 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 */
  • 9.
  • 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...
  • 19.
  • 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
  • 22.
  • 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 ADOBE EDGE 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/