Funcionamiento
Funciona dividiendo repetidamente por la mitad la parte de la lista que podría contener el elemento, hasta que haya reducido las ubicaciones posibles a solo una.

Implementación
export class BinarySearch { private array: number[] private target: number private middle = 0 constructor(shortedList: number[], target: number) { this.array = shortedList this.target = target } public execute(left = 0, rigth = this.array.length - 1): number { if (left > rigth) { this.middle = -1 return this.middle } this.middle = Math.floor((left + rigth) / 2) if (this.target > this.array[this.middle]) { this.execute(this.middle + 1, rigth) } if (this.target < this.array[this.middle]) { this.execute(left, this.middle - 1) } return this.middle }}const shortedList = [10, 40, 45, 59, 80, 91]const binarySearch = new BinarySearch(shortedList, 2)const result = binarySearch.execute()console.log(`The index is ${result} and its value is ${shortedList[result]}`)