title: Are there more short and tricky codes in javascript?
body: <p>I found the following short and tricky codes on<br>
  <br>
  Double bitwise NOT (~~) - James Padolsey<br>
  <a href="http://james.padolsey.com/javascript/double-bitwise-not/" rel="nofollow">http://james.padolsey.com/javascript/double-bitwise-not/</a><br>
  <br>
  Web Reflection: Two simple tricks in JavaScript ( olds, but always useful )<br>
  <a href="http://webreflection.blogspot.com/2008/06/two-simple-tricks-in-javascript-olds.html" rel="nofollow">http://webreflection.blogspot.com/2008/06/two-simple-tricks-in-javascript-olds.html</a><br>
  <br>
  <br>
  double bitwise not<br>
  <br>
  <code>Math.round(v)</code> === <code>~~v</code><br>
  <br>
  <code>Math.floor(v)</code> === <code>~~v</code> (if v > 0)<br>
  <br>
  <code>isNaN(Number(v)) ? 0 : Number(v)</code> === <code>~~v</code>(if v is not float)<br>
  <br>
  <br>
  double not<br>
  <br>
  <code>Boolean(v)</code> === <code>!!v</code><br>
  <br>
  (<code>!Boolean(v)</code> === <code>!v</code>)<br>
  <br>
  bitwise shift<br>
  <br>
  <code>Math.round(v / 2)</code> === <code>v &gt;&gt; 1</code><br>
  <br>
  <code>Math.round(v)</code> === <code>v &gt;&gt; 0</code><br>
  <br>
  <br>
  single bitwise not<br>
  <br>
  <code>a.indexOf(v) !== -1</code> === <code>~a.indexOf(v)</code><br>
  <br>
  <br>
  Are there more short or tricky codes in javascript?<br></p>