Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A small wrapper that implement the binary search algorithm in javascript, a lot faster than using a loop

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 array.js initial commit November 11, 2010
Octocat-spinner-32 index.html initial commit November 11, 2010
Octocat-spinner-32 readme.md
Octocat-spinner-32 searchBinary.js initial commit November 11, 2010
Octocat-spinner-32 searchNormal.js initial commit November 11, 2010
readme.md

Binary search algorithm

With this little helper you just pass your array and what you are looking for and it will return you back a result array, a typical use would look like this:

var searchResult = searchBinary("m", array, true)
the parameters are : searchBinary(search string, array to search, case insensitive?)

This will return an array with all items starting by the letter m. A good use of this script would be with a auto-complete widget.

For more informations: http://www.position-absolute.com/articles/optimizing-a-search-functionality-with-large-javascript-arrays/

Something went wrong with that request. Please try again.