Javascript - what does != -1 do in this function : <p>I understand practically all of this code except the lines noted below</p>

<pre><code>function hasEvent(event, entry) {
  return entry.events.indexOf(event) != -1; /*?????????*/
}

function tableFor(event, journal) {
  var table = [0, 0, 0, 0];
  for (var i = 0; i &lt; journal.length; i++) {
    var entry = journal[i], index = 0;
    if (hasEvent(event, entry)) index += 1;
    if (entry.squirrel) index += 2;
    table[index] += 1;
  }
  return table;
}

console.log(tableFor("pizza", JOURNAL));
// → [76, 9, 4, 1]
</code></pre>

<p><code>JOURNAL</code> is an array. This function loops through it to find if any of the entries hold the value of pizza, and what the value of the property of <code>squirrel</code> is. Based on the results of those two checks, 1 is added to one of the 4 index in <code>table</code>. I guess I'm not understanding what the <code>hasEvent</code> function does, and how it interacts with the first <code>if</code> statement. </p>

<p>For more details, code can be found about halfway through this page</p>

<p><a href="http://eloquentjavascript.net/04_data.html" rel="nofollow noreferrer">http://eloquentjavascript.net/04_data.html</a></p>
