title: Optional parameters in Meteor router
body: <p>I have a path in Meteor</p>
  
  <pre><code>path: '/my-url/:groupId?',
  </code></pre>
  
  <p>I have added the question mark to indicate that sometimes <code>groupId</code> is not used. In <code>data</code> I check whether the group id is set with <code>this.params.hasOwnProperty('groupId')</code> but I have come across that sometimes the router thinks groupId is set even if it isn't (don't know why) but the value is <code>undefined</code>.</p>
  
  <p>Therefore, I tried</p>
  
  <pre><code>console.log(this.params.hasOwnProperty('groupId'));
  console.log('groupId' in this.params);
  console.log(this.params.groupId);
  </code></pre>
  
  <p>and they evaluate to</p>
  
  <pre><code>&gt; true
  &gt; true
  &gt; undefined
  </code></pre>
  
  <p>So I guess <code>hasOwnProperty</code> is not the best way to check whether <code>groupId</code> is set since it doesn't check for undefined values.</p>
  
  <p>What will be a better way to check this? Why does <code>hasOwnProperty</code> evaluate to true even if my url is <code>/my-url</code>?</p>