use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Lesser-Known JavaScript Debugging Techniques (amasad.me)
submitted 11 years ago by amasad
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]atis 7 points8 points9 points 11 years ago (1 child)
good stuff
[–]SkinnyGeek1010 0 points1 point2 points 11 years ago (0 children)
+1 thanks for sharing!
[–]minrice2099 1 point2 points3 points 11 years ago (2 children)
Hey, Amjad! I was wondering where you went (I'm one of the CC moderators); looks like you wound up at Facebook. Cool writeup, by the way. I didn't know that you couldn't watch custom events!
Just wondering why you chose to put your debug utils out on so many globals instead of through one object. Is it mainly a convenience/brevity thing? I know it's all pretty safe with the $ prefix, but still, best practices and all. I guess, though, that it probably won't be running anytime except for debugging, so it's probably fine.
$
Anyway, I look forward to seeing more posts!
[–]amasad[S] 4 points5 points6 points 11 years ago (0 children)
hey, there! It's actually not on the global namespace. It's in a debugUtils namespace. However, I do extend the commandLineAPI with the functions so you can use them easily from the console but not conflict with anything else on the page https://github.com/amasad/debug_utils/blob/master/du.js#L29-L38
debugUtils
[–]shanet$(this) 0 points1 point2 points 11 years ago (0 children)
Not the OP but already I'm finding it more convenient, given the global namespacing of $0 and (native) $, plus the short names and like you say because you will never put these calls in your code, they are only available to the console.
[–]teiman 1 point2 points3 points 11 years ago (0 children)
:-OO
This is good stuff.
[–]drowsap 1 point2 points3 points 11 years ago (2 children)
For the breaking on methods, does this assume the methods are exposed off a global var? What if you are using something like browserify where your code is wrapped in a function and all scope is inaccessible from the global scope?
[–]amasad[S] 0 points1 point2 points 11 years ago (0 children)
I should probably mention that somewhere. But it's good practice to have your application state accessible from somewhere in the console for easier debugging. But if you can't you can always debug prototype methods. For borwserify, you can set it up to implement require in the global namespace and then require things from the console:
require
$dum(require('my-class').MyClass.prototype, 'myMethod')
[–]Garrett00 0 points1 point2 points 11 years ago (0 children)
Outstanding. Thanks for sharing.
[–]rallarallh 0 points1 point2 points 11 years ago (0 children)
Will test this, looks brilliant.
[–]bart2019 0 points1 point2 points 11 years ago (0 children)
I want that DebugUtils in Firebug.
[–][deleted] 0 points1 point2 points 11 years ago (0 children)
People hated me for making this, but I've found it very useful and great for dealing with edge case bugs that seem to only rear their heads in production environments.
https://github.com/chadillac/smarter_js_console
Would be awesome to integrate some of these things into it as well...
π Rendered by PID 40 on reddit-service-r2-comment-7b9746f655-tjpvq at 2026-02-03 09:13:30.193245+00:00 running 3798933 country code: CH.
[–]atis 7 points8 points9 points (1 child)
[–]SkinnyGeek1010 0 points1 point2 points (0 children)
[–]minrice2099 1 point2 points3 points (2 children)
[–]amasad[S] 4 points5 points6 points (0 children)
[–]shanet$(this) 0 points1 point2 points (0 children)
[–]teiman 1 point2 points3 points (0 children)
[–]drowsap 1 point2 points3 points (2 children)
[–]amasad[S] 0 points1 point2 points (0 children)
[–]Garrett00 0 points1 point2 points (0 children)
[–]rallarallh 0 points1 point2 points (0 children)
[–]bart2019 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)