title: Variable name as a string in Javascript
body: <p>Is there a way to get a variable name as a string in Javascript? (like <a href="https://developer.apple.com/documentation/foundation/1395257-nsstringfromselector" rel="noreferrer"><code>NSStringFromSelector</code></a> in <a href="https://en.wikipedia.org/wiki/Cocoa_(API)" rel="noreferrer">Cocoa</a>)</p>
  
  <p>I would like to do like this:</p>
  
  <pre><code>var myFirstName = 'John';
  alert(variablesName(myFirstName) + ":" + myFirstName);
  
  --&gt; myFirstName:John
  </code></pre>
  
  <hr>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I'm trying to connect a browser and another program using JavaScript. I would like to send instance names from a browser to another program for callback method:</p>
  
  <pre><code>FooClass = function(){};
  FooClass.someMethod = function(json) {
    // Do something
  }
  
  instanceA = new FooClass();
  instanceB = new FooClass();
  doSomethingInAnotherProcess(instanceB); // result will be substituted by using instanceB.someMethod();
  
  ...
  </code></pre>
  
  <p>From another program:</p>
  
  <pre><code>evaluateJavascriptInBrowser("(instanceName).someMethod("resultA");");
  </code></pre>
  
  <p>In PHP:
  <a href="https://stackoverflow.com/questions/255312/how-to-get-a-variable-name-as-a-string-in-php/255335#255335">How to get a variable name as a string in PHP?</a></p>