title: TypeError: Cannot find function When using Array.prototype
body: <p>I have a very simple function I am trying to add to an array. I have seen examples on this site where people have extended different simple items, like String &amp; Array. But I also have seen comments where Google doesn't allow you to extend certain classes. But from what I can tell, that was only for custom Google classes, like Spreadsheet, Range, etc.</p>
  
  <p>Why is this throwing a TypeError? Tried to use the same function I <a href="https://stackoverflow.com/questions/18482143/google-scripts-search-spreadsheet-by-column-return-rows">found here</a>.</p>
  
  <pre><code>Array.prototype.findIndex = function(search){
    if(search == "") return false;
    for (var i=0; i&lt;this.length; i++)
      if (this[i] == search) return i;
  
    return -1;
  } 
  
  //Do a search on a specific range, find the correct ID, and do a lookup based on ID
  function onEdit(e) {
    var e = {};
    e.value = "Test String";
    var client = e.value;
    var columnValues = mydoc.getRangeByName(categoryRangeName).getValues();
  
    //columnValues returns 2D array of values
    //https://developers.google.com/apps-script/reference/spreadsheet/range#getValues()
    var searchResult = columnValues.findIndex(e.value);  //**ERROR HERE**
  
  }
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I will also add, that I set the method to just return a value like this just to test that there was no problem with the prototype, and it failed on the same error.</p>
  
  <pre><code>Array.prototype.findIndex = function(val) {
    return val;
  } 
  </code></pre>
  
  <p>And I created a function with the same for loop, and it works just fine.</p>
  
  <pre><code>function findIndex(vals, search) {
    if(search == "") return false;
    for (var i=0; i&lt;vals.length; i++)
      if (vals[i] == search) return i;
  
    return -1;
  }
  </code></pre>