title: Does indexOf != -1 return a Boolean?
body: <p>I have just started learning Javascript and I have a specific question about a specific piece of code below. It is part of the lycanthrope's log in chapter 4 of Eloquent Javascript. Because of the specificity of my question I haven't included all the other code associated with this problem for I believe it isn't necessary to answer my question. </p>
  
  <p>Please do let me know if this is considered 'bad practice' and I will make sure to ammend this and/or future posts to show more background.</p>
  
  <p>In the code below the second line shows a return. So far I have learned that indexOf returns a positive number or zero if and only if it finds an occurence of whatever is passed in it. If no occurence is found it returns -1.</p>
  
  <p>In this case it is followed by != -1, which I understand to mean "not equal to minus 1". That is clear to me.</p>
  
  <p>What I do not completely understand is what the actual return in line 2 ends up being. Does it return a Boolean value of either true or false? Or does it return he actual index where the 'event' is found? </p>
  
  <p>Further on, in the first if-statement, we see the hasEvent variable again. I read this statement as "If hasEvent(event, entry) is true then add 1 to the index.</p>
  
  <p>Am I 'reading' this right and is the return in the second line indeed a Boolean?</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;
  }
  </code></pre>
  
  <p>Thank you for your help and please tell me if I should have stated this question differently! I am trying to make sure I understand things before I move on!</p>