title: Javascript - set a variable using concatenation of strings
body: <p>Is it possible to set a variable by concatenating two strings together to form the name? </p>
  
  <p>If at all possible I'd like to determine what variable to set based on the class names of the objects that the user clicks. I know I can hard code a bunch of if/else if statements, but it would be really cool if I could reference the variables indirectly. I was thinking something like this:</p>
  
  <pre><code>var owner_read;
  var group_read;
  
  function setVariableIndirectly(object){
      var second = object.className; // returns "read"
      var first = object.parentElement.className; // returns "group"
  
      first + "_" + second = "set this as the new variable";
  }
  </code></pre>
  
  <p>Is there any way of doing this??</p>
  
  <p>EDIT:</p>
  
  <p>Here's the html that the data is coming in from.</p>
  
  <pre><code>&lt;p class="owner"&gt;
      &lt;span class="read" onclick="permissionClick(this)"&gt;r&lt;/span&gt;
      &lt;span class="write" onclick="permissionClick(this)"&gt;w&lt;/span&gt;
      &lt;span class="execute" onclick="permissionClick(this)"&gt;x&lt;/span&gt;
  &lt;/p&gt;
  </code></pre>