title: Getting the object variable name in JavaScript
body: <p>I am creating a JavaScript code and I had a situation where I want to read the object name (string) in the object method. The sample code of what I am trying to achieve is shown below:</p>
  
  <pre><code>// Define my object
  var TestObject = function() {
      return {
          getObjectName: function() {
              console.log( /* Get the Object instance name */ );
          }
      };
  }
  
  // create instance
  var a1 = TestObject();
  var a2 = TestObject();
  
  a1.getObjectName(); // Here I want to get the string name "a1";
  
  a2.getObjectName(); // Here I want to get the string name "a2";
  </code></pre>
  
  <p>I am not sure if this is possible in JavaScript. But in case it is, I would love to hear from you guys how to achieve this.</p>