Searching..

How to binary search in JS

Stephan Bakkelund Valois

--

The binary search will search through a sorted dataset. It’s important that the data is sorted from the lowest to the highest value, or else the binary search wouldn’t work. If your data isn’t sorted, you need to sort it before you can search over it with binary search.

The binary search is of O(log n) complexity. which basically means it will cut the data in half with each iteration, until it finds the target value…

--

--