title: Optimum way to compare strings in JavaScript?
body: <p>I am trying to optimize a function which does binary search of strings in JavaScript.</p>
  
  <p>Binary search requires you to know whether the key is <code>==</code> the pivot or <code>&lt;</code> the pivot.</p>
  
  <p>But this requires two string comparisons in JavaScript, unlike in <code>C</code> like languages which have the <code>strcmp()</code> function that returns three values <code>(-1, 0, +1)</code> for (less than, equal, greater than).</p>
  
  <p>Is there such a native function in JavaScript, that can return a ternary value so that just one comparison is required in each iteration of the binary search?</p>