Many JS host environments provide a 'debugger' that invokes an interactive debugger. For example:
I use both of these quite frequently. I was wondering if, in environments that support this, there was a way I could create an alias for the debugger, eg. so:
d
has the same effect as
debugger
Is this possible?
debugger
is a keyword and it's not possible to delegate it's special meaning to a variable (you will find a similar question about aliases here).
You can wrap debugger
with a function:
d = function() {
debugger;
};
and invoke it using d()
. It will shorten the syntax, but you will have to always travel one level up in the call stack to get to the code that you are actually trying to debug.
In my opinion you should simply set up a snippet (or a "live template") in your editor/IDE that will replace key combination d + TAB
with debugger;
.