title: How do I handle indexOf returning 'null' without using try/catch(err)?
body: <p>I'm populating a table with data - using <code>fixed-data-table</code>, which is  a React.js component. However, that isn't so important at this stage.</p>
  
  <p>The table has a search box where the issue stems from.</p>
  
  <p>First, here's the interesting part of the code.</p>
  
  <pre><code>for (var index = 0; index &lt; size; index++) {
              if (!filterBy || filterBy == undefined) {
                  filteredIndexes.push(index);
              }
              else {
  
                  var backendInfo = this._dataList[index];
  
                  var userListMap = hostInfo.userList;
  
                  var userListArr = Object.values(userListMap);
  
  
                  function checkUsers(){
                      for (var key in userListArr) {
                          if (userListArr.hasOwnProperty(key) &amp;&amp; userListArr[key].text.toLowerCase().indexOf(filterBy) !== -1) {
                              return true;
                          }
                      }
                      return false;
                  }
  
  
                  if (backendInfo.firstName.indexOf(filterBy) !== -1 || backendInfo.lastName.toLowerCase().indexOf(filterBy) !== -1 || backendInfo.countryOrigin.toLowerCase().indexOf(filterBy) !== -1
                      || backendInfo.userListMap.indexOf(filterBy) !== -1) {
                      filteredIndexes.push(index);
                  }
  
              }
          }
  </code></pre>
  
  <p>This is rendered and the last part is throwing errors if you input something in the table, and a column returns <code>null</code> from the user input.</p>
  
  <p>The thing is, I can make the code work if I change the last part to ..</p>
  
  <pre><code>        try {
              if (backendInfo.firstName.indexOf(filterBy) !== -1 || backendInfo.lastName.toLowerCase().indexOf(filterBy) !== -1 ||    backendInfo.countryOrigin.toLowerCase().indexOf(filterBy) !== -1
              || backendInfo.userListMap.indexOf(filterBy) !== -1) {
              filteredIndexes.push(index);
              }
          }
          catch(err) {
              console.log('Exception')
          }
  </code></pre>
  
  <p>With the try/catch, it works 100% as intended and handles the indexOf returning null... But this can't be the way to properly handle it - I'm assuming this sort of exception handling is, well, supposed to be for rare exceptions, and shouldn't really be used on the front-end as much as the backend. </p>
  
  <p>How do I handle indexOf returning null in the above Javascript code? It might return null in any of the sources columns that are being populated. </p>