title: Can I get function's constructor's variable name in JavaScript?
body: <p>I'm wondering if i can get something like this:</p>
  
  <pre><code>function foo() {
      console.log(xxx);
  }
  
  var myFunc = new foo();
  </code></pre>
  
  <p>I want <code>console.log</code> to give me <code>'myFunc'</code> string (or object, or anything I can reference to for that matter)</p>
  
  <p>Is that at all possible in JavaScript?</p>
  
  <p>Sorry for my poor language - not a native speaker and a self-taught developer :)</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Maybe I should explain the reason for why I "need" this. Let's say I have a plugin that creates an interactive object in DOM. I can receive events from other object (WebSocket) that can be viable to any created object, but I can't be sure which one. Of course, I can handle this by creating some helper objects and/or functions, but it would really help to make my code a bit clearer if I could reference that object based on some DOM element that exists on the page.</p>
  
  <p>It would be great if I could add a <code>data</code> attribute to an element that contains said created interactive object, and then - by finding a class name that exists within it - reference a variable that was constructed based on that constructor function.</p>
  
  <p>Yes, I realize that this is not the best way to handle this situation, but:</p>
  
  <ol>
  <li>This would reduce code complexity in my case</li>
  <li>I'm just wandering if it's possible :)</li>
  </ol>