title: Javascript: How to find key name in array of objects
body: <p>I am trying to determine if a key name is present in my array of object. As an example, how would I verify if the key with a name of 'name' equals the argument passed in my function call? Below is code to further clarify.</p>
  
  <pre><code>var stooges = [{name: 'moe', age: 40}, {name: 'larry', age: 50}, {name: 'curly', age: 60}];
  var test = function(arr, propName){
  var result = [];
  for(var i = 0; i &lt; arr.length; i++){
      if(arr[i][propName] === propName){
          result.push(arr[i][propName]);
      }
  }
  return result;
  } 
  func(stooges, "name"); 
  </code></pre>