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

The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
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
 

Recently uploaded (20)

The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
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
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
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
 

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/