How to check class and function existence?
<pre><code>var a, kdApi;
a = (function() {
  function a() {}
  a.prototype.b = function() {
    return "foo";
  };
  return a;
})();
kdApi = (function() {
  function kdApi(className, funcName) {
    if (typeof [className] !== "undefined" &amp;&amp; ([className] != null)) {
      eval("cu= new " + className + "()");
      if (cu[funcName]) {
        console.log("class and function exists");
      } else {
        console.log("class does, function doesn't");
      }
    } else {
      console.log("both class and function doesn't.");
    }
  }
  return kdApi;
})();
new kdApi("w", "b");
</code></pre>

<p>When I run this, I want to get both class and function doesn't exist message but instead I get w is not defined error. What am I doing wrong?  Also, can I do it without <code>eval</code>?</p>
