Pregunta de entrevista de Apptware

Explain the logic behind the Binary Search and write a JavaScript program illustrating the same.