Pergunta de entrevista da empresa Apptware

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