calling a dynamic function in javascript

Posted by scatman on Stack Overflow See other posts from Stack Overflow or by scatman
Published on 2010-05-21T10:32:08Z Indexed on 2010/05/21 10:40 UTC
Read the original article Hit count: 214

Filed under:
|

is it possible to call a dynamic method in javascript. ie suppose i have in my page 2 methods as such:

function id1_add()
{
  return 1;
}

function id2_add()
{
  return 2;
}

i also have this function:

function add()
{
  var s1='id1';

  s1+'_add()'; //???
}

is it possible to call for example id1_add() in such:

 s1+'_add()'; 

so the method call depends on a previous string?

© Stack Overflow or respective owner

Related posts about asp

Related posts about JavaScript