The function which will remain anonymous
Invoking and displaying functions variably
Suppose we wish to invoke a function, but which function will vary as a function of user-defined events. Or suppose we wish to know which function has called another, without specifically sending a parameter. Or what if we want to read or display the source code of a given function? How to do this? Read on.
The <select> (below, left) activates a function by name, by sending the select's value to a "metafunction"
<select name="s" size="5" onchange="metafunction(s.value)">
The metafunction displays the parameter passed (a), the source of the associated function eval(a) and the output of the function when run eval(a)(a). Choosing f6 will display the source of the metafunction
choose a function argument
a=s.value
s
selected
value
becomes
s.value
function source
eval(a)
function output
eval(a)(a)
Explanation
Visit this page for an example which finds all the functions in a given web page (in IE) and then builds a menu containing them.