Well I came up with a hack sort of way to do it. In case you are wondering why I wanted this functionality, I am trying to put together a better closure breakpoint (I hate the IE debugger, thank god for FireBug) like
http://trimpath.com/project/wiki/TrimBreakpoint
Basically, I found that arguments.callee is the function, so I do a toString() on it then parse it for variable names. I have no doubt some might slip by my parsing depending on how it is declared, but it seems to get most of them (at least the way I declare them).
Here's the code to parse the function in case you are interested
Code:
function getLocals(args) {
var ret = [];
var reArg = /\(?\s*(\w+)\s*(,|\))/g;
var reHasVar = /\Wvar\W/;
var reGetVar = /(var|,)\s*(\w+)/g;
var a = args.callee.toString().split("\n");
var lookForArgs = true;
var reResult;
ret.push(a[0]); // save the function name for later use
for (var i = 0; i < a.length; i++) {
if (lookForArgs) {
while ((reResult = reArg.exec(a[i])) != null) {
ret.push(reResult[1]);
}
if (/\{/.test(a[i])) {
lookForArgs = false;
}
}
if (!lookForArgs) {
if (reHasVar.test(a[i])) {
while ((reResult = reGetVar.exec(a[i])) != null) {
ret.push(reResult[2]);
}
}
}
}
return(ret);
}
It's called like
getLocals(arguments);
and returns an array of arguments and local variable names which I can iterate through using eval to get the values.
Thanks again. I imagine without your help I'd still be searching the web for some way it is exposed by the browser.
david_kw