Thursday, June 21st, 2007
DP_Debug: JavaScript Debugging Extensions
Jim Davis has released a simple little JavaScript dumping library, DP_Debug, that supports circular and recursive references, most system objects and specifies certain otherwise ambiguous conditions. It allows for depth of recursion control, labeling and interactive collapse/expand of results. It’s based in essence on the ColdFusion CFDUMP.
In addition the library allows for simple access to Query String and Cookie values and provides basic logging, code timing support and program integration support (the ability to enable or disable debugging). There’s also built in quick reference documentation.
- dump(): Converts JavaScript objects (their properties, values and relationships) to an HTML representation and displays this in the console for review. It supports objects with circular/recursive references. It’s similar to the insanely useful CFDUMP tag in ColdFusion.
- dumpCookies(): A convenience method which dumps all available browser cookies to the console.
- dumpQueryString(): A convenience method which dumps all available query-string names and values to the console.
- logger(): A method for logging messages to the console using either custom or predefined types. logInfo(), logWarning() and logError() are all shortcut methods for logging specific types of messages easily.
- timer(): A method for timing blocks of code.
- getType(): Provides more advanced Object type-recognition than the native “typeof” operator.





As a ColdFusion developer, I have to say that having a like functionality in Javascript is a beautiful thing.
Firebug still rules 8)
Why would someone want to use this instead of Firebug?
what could be great is to have this extra added functionality integrated into firebug… we don’t need another logger or another timer, yet it’s great to be able to dump objects in a cleaner way than firebug does.
Because some of us test in browsers besides Firefox?
Full disclosure: I’m the author of the component. To answer the “Firebug” comments:
a) The component isn’t actually new – it’s almost two years old. I think it actually came out originally about the same time as FireBug.
b) The component is pure JS – not a browser add-in. It doesn’t require an install and can be embedded in the app such that debugging can be enabled interactively from any supported browser.
c) The component works in IE 6+, FireFox 1+ and Opera 9+ (and probably others). FireBug doesn’t.
I love FireBug – this isn’t a replacement by any means. It really does serve a different function.
Just for completeness:
Have a look at: http://getfirebug.com/lite.html
But this doesn’t mean that you lib isn’t useless, so keep on working.
Damn, should be (to fast this morning):
But this doesn’t mean that you lib is useless, so keep on working.
Everyone should decide for her-/himself which tool to use.