title: Retrieving Keys from JSON Array key-value pair dynamically - Javascript
body: <p>I have a question that would like to seek your expertise on.</p>
  
  <p>This is a JSON array that I have:</p>
  
  <pre><code>[{"A":20,"B":32,"C":27,"D":30,"E":40}]
  </code></pre>
  
  <p>What I would like to do is to retrieve the keys (A, B, C, D, E) from the JSON array instead of the values. I am able to retrieve the values but not the keys.</p>
  
  <p>I am using this to retrieve the values dynamically:</p>
  
  <pre><code>function calculateSum(jsonArray) {
      var result = 0;
      for (var i = jsonArray.length - 1;  i &gt;= 0; --i)
      {
          var o = jsonArray[i];
          A = o.A;
          B = o.B;
          C = o.C;
          D = o.D;
          E = o.E;
          result = A + B + C + D + E;
          return result;
      }
  
      return result;
  }
  </code></pre>
  
  <p>Similarly, what should I do to retrieve the <strong>keys</strong> using JavaScript?</p>