Skip to content

Instantly share code, notes, and snippets.

@imsickofmaps
Created November 26, 2013 09:53
Show Gist options
  • Select an option

  • Save imsickofmaps/7655866 to your computer and use it in GitHub Desktop.

Select an option

Save imsickofmaps/7655866 to your computer and use it in GitHub Desktop.
use this for searching a javascript array for partial matches
Array.prototype.getIndexes = function(what) {
var indexes = [], what = what.toLowerCase();
if (!what.length)
return indexes;
this.forEach(function(el, index) {
console.log(el.toLowerCase().indexOf(what))
if (el.toLowerCase().indexOf(what)!=-1)
indexes.push(index);
});
return indexes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment