Am I understanding this correctly? Filter method

Am I understanding this correctly? Filter method
0

#1
var fruits = ['apple', 'banana', 'grapes', 'mango', 'orange'];

function filterItems(query) { // this would be 'ap' in the example below
  return fruits.filter(function(el) { // is the el the full value from fruits array passed in? so, 'apple', etc.
      return el.toLowerCase().indexOf(query.toLowerCase()) > -1; 
      // same as 'ap'.toLowerCase().indexOf('apple'.toLowerCase()) > -1
     // why is it -1? what does it mean here?
  })
}

console.log(filterItems('ap')); // ['apple', 'grapes']
console.log(filterItems('an')); // ['banana', 'mango', 'orange']

#2

el represents each element of the fruits array when iterating through the array

In the first iteration of the filter function, this would be the same as:
‘apple’.toLowerCase().indexOf(‘ap’.toLowerCase()) > - 1

The indexOf function returns an integer between 0 (inclusive) and the length of the string (exclusive) which represents the first index in the string where the character(s) are found. It will return -1 if it does not find a match. If ‘apple’.toLowerCase().indexOf(‘ap’.toLowerCase()) is greater than 1, then the expression evaluates to true and the filter function adds the current element (el) to a new “filtered” array.