I want to do the opposite of Get JavaScript function-object from its name as a string?
That is, given:
function foo()
{}
function bar(callback)
{
function bar(callback){
var name=callback.toString();
var reg=/function ([^\(]*)/;
return reg.exec(name)[1];
}
>>> function foo() { };
>>> bar(foo);
"foo"
>>> bar(function(){});
""
If you were looking for the function on an specific object event, this may help:
var a = document.form1
a.onsubmit.name