title: Permission denied to access property 'toString'
body: <p>I'm trying to find a generic way of getting the name of Constructors. My goal is to create a Convention over configuration framework for KnockoutJS</p>
  
  <p>My idea is to iterate over all objects in the window and when I find the contructor i'm looking for then I can use the index to get the name of the contructor</p>
  
  <p>The code sofar</p>
  
  <pre><code>(function() {
      constructors = {};
      window.findConstructorName = function(instance) {
          var constructor = instance.constructor;
          var name = constructors[constructor];
          if(name !== undefined) {
              return name;
          }
  
          var traversed = [];
          var nestedFind = function(root) {       
              if(typeof root == "function" || traversed[root]) {
                  return       
              }
  
              traversed[root] = true;
              for(var index in root) {               
                  if(root[index] == constructor) {
                      return index;
                  }
  
  
                  var found = nestedFind(root[index]);  
                  if(found !== undefined) {
                      return found;
                  }
              }
          }
  
          name = nestedFind(window);
          constructors[constructor] = name;
          return name;
      }
  })();
  
  var MyApp = {};
  MyApp.Foo = function() {
  };
  
  var instance = new MyApp.Foo();
  console.log(findConstructorName(instance));     
  </code></pre>
  
  <p>The problem is that I get a <code>Permission denied to access property 'toString'</code> Exception, and i cant even try catch so see which object is causing the problem</p>
  
  <p>Fiddle <a href="http://jsfiddle.net/4ZwaV/" rel="noreferrer">http://jsfiddle.net/4ZwaV/</a></p>
  
  <p><strong>Final version in this fiddle</strong>
  <a href="http://jsfiddle.net/2Uvd5/8/" rel="noreferrer">http://jsfiddle.net/2Uvd5/8/</a></p>
  
  <p><strong>Check here for the embryo of my Convention over configuration plugin</strong>
  <a href="https://github.com/AndersMalmgren/Knockout.BindingConventions" rel="noreferrer">https://github.com/AndersMalmgren/Knockout.BindingConventions</a></p>