title: What's the fastest way to square a number in JavaScript?
body: <p>What's the fastest way to square a number in JavaScript?  </p>
  
  <pre><code>function squareIt(number) {
     return Math.pow(number,2);
  }
  
  function squareIt(number) {
     return number * number;
  }
  </code></pre>
  
  <p>Or some other method that I don't know about.  I'm not looking for a golfed answer, but the answer that's likely to be shortest in the compiler, on the average.</p>
  
  <p>Edit: I saw <a href="https://stackoverflow.com/questions/1377430/why-is-squaring-a-number-faster-than-multiplying-two-random-numbers">Why is squaring a number faster than multiplying two random numbers?</a> which seemed to indicate that squaring is faster than multiplying two random numbers, and presumed that n*n wouldn't take advantage of this but that Math.pow(n,2) would.  As jfriend00 pointed out in the comments, and then later in an answer, <a href="http://jsperf.com/math-pow-vs-simple-multiplication/10" rel="noreferrer">http://jsperf.com/math-pow-vs-simple-multiplication/10</a> seems to suggest that straight multiplication is faster in everything but Firefox (where both ways are similarly fast).</p>