<p>There are several different methods for converting floating point numbers to Integers in JavaScript. My question is what method gives the best performance, is most compatible, or is considered the best practice?</p>

<p>Here are a few methods that I know of:</p>

<pre><code>var a = 2.5;
window.parseInt(a); // 2
Math.floor(a);      // 2
a | 0;              // 2
</code></pre>

<p>I'm sure there are others out there. Suggestions?</p>

parseInt() is probably the best one.
```
a | 0
```
doesn't do what you really want (it just assigns 0 if a is an undefined or null value, which means an empty object or array passes the test), and Math.floor works by some type trickery (it basically calls parseInt() in the background).