title: How can I make a function that checks for duplicates return false if the input is null?
body: <p>I am using this code to check for a duplicate:</p>
  
  <pre><code>        var duplicate = _.some(this.home.modal.data.subTopics, function (subTopic) {
              return subtopic.subTopicId === this.home.modal.subTopicId;
          });
  </code></pre>
  
  <p>It checks the <code>subTopicId</code> of each row in <code>home.modal.data.subTopics</code> to see if any match the value of this.home.modal.subTopicId. </p>
  
  <p>However I have a problem if <code>this.home.modal.subTopicId</code> is null and it gives an error. </p>
  
  <p>How can I change it so that it would never show a duplicate if this.home.modal.subTopicId was null? Ideally I would like to change it in the return area of the code but I am not sure how I could do this.</p>