title: Math.floor() | 0
body: <p>I have often seen this in JavaScript:</p>
  
  <pre><code>var val = (myvar / myothervar) | 0;
  </code></pre>
  
  <p>Which as far as I understood was one of the many shortcuts to floor a value in JavaScript (like <code>~~</code>, and <code>&gt;&gt; 0</code>, etc). However, I was looking at a piece of code recently that did this:</p>
  
  <pre><code>var val = Math.floor(myvar/ myothervar)|0;
  </code></pre>
  
  <p>They used <code>Math.floor()</code> and then also did a bitwise OR with <code>0</code>. The author did this many times, so it wasn't just a typo they did once. What do you gain by doing both?</p>
  
  <p>For the curious, the code I am referring to can be found <a href="https://github.com/chrisdickinson/collide-2d-tilemap/blob/5842f95f5d22fb3ce4741d1189cc7881510226d5/index.js#L35" rel="nofollow noreferrer">here</a></p>