Functions passed as arguments

Giganews Newsgroups
Subject: Functions passed as arguments
Posted by:  Richard A. DeVenezia (radeve…
Date: Mon, 1 Sep 2003

I have a function source() to show the definitions of functions passed to it

function sourceAsHTML() {
  var s=''
  for (var i=0; i<arguments.length; i++) {
    s +=
  + arguments[i].toString().replace (/</g, '&lt;')
  + '</PRE>'
  return s

and it works nicely, except in the case of a class prototype assigned to an
anonymous function

function myClass () {}
function myClass.prototype.foobar = function () { /* foobar */ }

alert (sourceAsHTML(myClass.prototype.foobar))

the alert shows
<PRE>function () { /* foobar */ }</PRE>
which is close, but it doesn't show that it 'belongs' to

So the question is, when passed a function as an arg is there a way to know
the function name or context (i.e. prototype) ?

Richard A. DeVenezia