<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body>
You refer to the function object without the parentheses:<br>
<font face="Courier New, Courier, monospace"><br>
function myFunction()<br>
{<br>
&nbsp;&nbsp;&nbsp; //do something here<br>
}<br>
<br>
functionList=new Array();<br>
<br>
functionList["myFunction"]=myFunction;</font><br>
<br>
Then to execute the function, you use the parentheses:<br>
<br>
<font face="Courier New, Courier, monospace">functionList["myFunction"]();</font><br>
<br>
<br>
Peter Brunone wrote:<br>
<blockquote cite="mid20040120185521.1FCFC30A0DE@LaTech.edu" type="cite">
  <pre wrap="">   But how do you get the array to point to the *execution* of the function rather than the return value of the function?  That is, if I want to set functionList["myFunction"] equal to myFunction(), how do I get it in there so that I can use it?

   IMO, this is a great discussion; keep it coming!

Original Message:
  </pre>
  <blockquote type="cite">
    <pre wrap="">From: Jeff Greenberg <a class="moz-txt-link-rfc2396E" href="mailto:jeff@websciences.org">&lt;jeff@websciences.org&gt;</a>
    </pre>
  </blockquote>
  <pre wrap=""><!---->
  </pre>
  <blockquote type="cite">
    <pre wrap="">One of the easiest ways to call a function based on a string is to index 
into an array or an object like so:

functionList["myFunction"]();

eval is not inherently bad or inefficient, it is just often used 
improperly or in cases where more thought should go into the design and 
architecture of the code. It is, in fact, indispensible if you are 
trying to extend the core javascript language or work with dynamically 
generated/modified code. It should not be used in "every day" code, and 
if you find yourself using it in a small bit of code, it is likely you 
are misusing it. Nothing is set in stone of course, and this is just a 
general guideline.

Peter Brunone wrote:

    </pre>
    <blockquote type="cite">
      <pre wrap="">  No problem; just start a new thread!

  What if you want to run a function based on a string?

-Peter B.
      </pre>
    </blockquote>
  </blockquote>
  <pre wrap=""><!---->

_______________________________________________
Javascript mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Javascript@LaTech.edu">Javascript@LaTech.edu</a>
<a class="moz-txt-link-freetext" href="https://lists.LaTech.edu/mailman/listinfo/javascript">https://lists.LaTech.edu/mailman/listinfo/javascript</a>

  </pre>
</blockquote>
</body>
</html>