title: Optimizing for loops in google apps script
body: <p>I am using for loops to search through large sheets (approximately 4500 rows). 
  Most of them look something like this:</p>
  
  <pre><code>function lookup(value) {
    var tables=SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Name");
    var columnvalues = tables.getRange(1, 1,tables.getLastRow()).getValues(); 
    var searchResult = columnvalues.findIndex(value); //Row Index - 1
  }
   Array.prototype.findIndex = function(search){
    if(search == "") return false;
    for (var i=0; i&lt;this.length; i++)
      if (this[i].toString().indexOf(search) &gt; -1 ) return i;
  
    return -1;
  }
  </code></pre>
  
  <p>The app script currently runs relatively slowly. I am looking for a way to either speed up my current code or for another search method. I've been thinking about using the google spreadsheet lookup functions (index-match, vLookup) but I haven't found a way to access those functions in apps script. Any thoughts? </p>