title: how to use variable for property in indexOf inside map function in Javascript
body: <p>I have a function as below:</p>
  
  <pre><code>getValue(param) {
      var result = [];
      result = this.state.ObjectsData.map(x =&gt; {
          if (result.indexOf(x.param) === -1) {
              result.push(x.param)
          }
      });
  }
  
  //ObjectsData is array of objects
  
  ObjectsData = [
      {tag: 23, name: vicky, gender: m},
      {tag: 13, name: sam, gender: m},
      {tag: 23, name: raj, gender: m}
  ]
  
  //x can be any object like below:
  x = {tag: 23, name: vicky, gender: m}
  </code></pre>
  
  <p>param is the propertyName like tag</p>
  
  <p>I am getting param as undefined at the below line even though the param has some value before map and after map at line
  <code>if (result.indexOf(x.param) === -1) { }</code></p>
  
  <p>I am trying to find unique values for any property like:
  for tag: 23, 13. And yes, x.tag or x.name or x.gender works fine but I want to make propertyName dynamic </p>