Avoid using eval() to call function by name with only dynamic string
<p>I have this simple switch block:</p>

<pre><code>function modifyServiceContractView(schema) {
     ...
}

function modifyContactView(schema) {
    ...
}


function addExtraInfoToSchema(defName, schema) {

  switch (defName) {

    case 'ServiceContractView':
      return modifyServiceContractView(schema);
      break;

    case 'ContactView':
      return modifyContactView(schema);
      break;

    default:
      return schema;

  }

}
</code></pre>

<p>instead of hardcoding a switch block, it would be nice to just have something like this instead:</p>

<pre><code>function modifyServiceContractView(schema) {
    ...
}

function modifyContactView(schema) {
    ...
}


function addExtraInfoToSchema(defName, schema) {

    return eval('modify' + defName+ '(schema)');

}
</code></pre>

<p>is there a better way to do this without eval()?</p>

<p>hopefully my question is clear.</p>