Meaning of [-1,1][+!!boolean_var]
<p>Can someone please explain the purpose of double-negating the <code>reverse</code> var in the below code?</p>

<pre><code>return function (a,b) {
   var A = key(a), B = key(b);
   return ((A &lt; B) ? -1 :
           (A &gt; B) ? +1 : 0)) * [-1,1][+!!reverse];                  
}
</code></pre>

<p>The way I understand it, the purpose is to pick the proper index from the <code>[-1,1]</code> array  to then use it in the multiplication but it seems to me that <code>[-1,1][+!!reverse];</code> could be safely replaced by <code>[-1,1][+reverse];</code></p>

<p>Am I wrong? What do you gain or prevent by double-negating <code>reverse</code> there? </p>

<p>I saw the above code on <a href="http://stackoverflow.com/a/979325/345490">this answer.</a></p>
