Pass an object property key, not its value, as a parameter in Javascript
<p>I am trying to write a simple, portable function where I can pass in an object.property and set its value from the result. Simple example: </p>

<pre><code>var myFunction = function (result){ 
  var data;
  //get some data
  return result = data;
};

myObject.someData;
myFunction(pass reference to key of myObject.someData here)
</code></pre>

<p>I want to pass reference to key of myObject.someData here. Brownie points for also declaring it here instead of line above.</p>

<p>Now for my actual code: </p>

<pre><code>var configurations;
var oldServer;
//make a call to get details of old server here

//helper function to stream json into a variable
var streamToString = function(stream, result) {
  var data = '';
  var chunk;

  stream.on('readable', function() {
      while ((chunk=this.read()) != null) {
          data += chunk;
      }
  });
  stream.on('end', function() {
    data = JSON.parse(data);
    return result = data;
  });
}

//declare shadowsocks as a property, so it can be passed as a param
configurations.shadowsocks;

//
streamToString(sequest.get('root@'+ oldServer[0].networks.v4[0].ip_address, '/etc/shadowsocks-libev/config.json', {
  privateKey: sshKey,
  readyTimeout: 20000
 }, function (error, stdout) {
   if (error) {
     throw error;
   }
 }), configurations.shadowsocks
);
</code></pre>

<p>I know I can do this the "wrong way" by doing:</p>

<pre><code> stream.on('end', function() {
        data = JSON.parse(data);
        return configurations.shadowsocks = data;
      });
    }
</code></pre>

<p>but then it's not portable. I would like to make this portable. </p>