iterative implementation
function binarySearch ( a , item , low , high ) { while ( low <= high ) { var mid = low + ( high - low ) / 2 ; if ( item == a [ mid ] ) return mid + 1 ; else if ( item > a [ mid ] ) low = mid + 1 ; else high = mid - 1 ; } return low ; }