Digging, Debugging

<witty subtitle here>

Hashtags: #digdebug #jqcon

Brian Arnold

@brianarn | randomthink.net

  • Senior Software Engineer @ Bazaarvoice
  • Previously a Lead Support & Senior Software Engineer at SitePen
  • Dojo core committer
  • Rock Band guitar expert

Outline

  • Non-technical tips
  • Understand the tools
  • Techniques

Non-technical Tips

Be open to learning

We are professional students

Learn JavaScript

No, really, learn the core

Read the spec, read JS: TDG thoroughly

lol

Rubber Duck

  • Colleagues
  • Friends at other shops
  • An actual rubber duck

Understand the tools

Command Line API

Originally pioneered in Firebug, now fairly ubiquitous

Feature support varies, learn your environment of choice

Moving between Elements and Console

  • $0
  • $_
  • inspect

Detailed viewing

  • console.*
  • dir
  • copy

STOP THE PRESSES

  • debugger;
  • Breakpoints
  • Watch things

Other types of breaks

  • DOM Breakpoints
  • XHR Breakpoints

Sources

  • Fuzzy finder opening
  • Pretty printing
  • Breaking on some/all errors

Profiling

  • Memory
  • Runtime

Techniques

(Here there be hacks)

Private Mode

Not just for hiding things

Use a style guide, damnit

Inconsistently written code can be awful

Look into things like Idiomatic for a starting point, and EditorConfig to help enforce it

You don't write code for yourself, you write it for the moron who has to maintain it in a year.

More often than not, you are that moron.

Breakpoint Actions

Use and abuse of conditional breakpoints for fun and profit*

* There may not be profit

Reading the stack

Which code is mine? Look for anonymous functions.

You can also name function expressions (can leak in IE6)

Digging through the stack

Resources