title: key value pair in javascript
body: <p>Applying filters in MongoDb</p>
  
  <p>I need to apply filters in mongoDb in an embedded document so how can I make a query like</p>
  
  <p>Example:</p>
  
  <pre><code>var query = {
  _id:userId,
  'match.Id':matchId,
  'match.userId':userId1
  }
  </code></pre>
  
  <p>now I want to apply filters lets suppose </p>
  
  <p>case 1: my query should be like</p>
  
  <pre><code> var query = {
      _id:userId,
      'match.Id':matchId,
  
      }
  </code></pre>
  
  <p>case 2 :</p>
  
  <pre><code> var query = {
      _id:userId,
      'match.userId':userId1
      }
  </code></pre>
  
  <p>there can be many cases like this</p>
  
  <p>So my question is how can I make this query object in node.js/javascript </p>
  
  <p>My work : I can create multiple key in an object but creating key as below doesn't works</p>
  
  <pre><code>var query={}
  query._id:userId // works
  query.'match.userId':matchId // error
  query.match.userId:matchId //error
  </code></pre>
  
  <p>tried below code got desired output but it comes with square bracket but type of arr is object</p>
  
  <pre><code>var arr = [];
  arr[ 'key3.abc' ] = "value3";
  arr[ 'key2.abc' ] = "value3";
  console.log(arr)//[ 'key3.abc': 'value3', 'key2.abc': 'value3' ]
  </code></pre>
  
  <p>desired output:</p>
  
  <pre><code>{'key3.abc': 'value3', 'key2.abc': 'value3'}
  </code></pre>