title: toString(16) with leading zeroes
body: <p>When you convert a small number to a hexadecimal representation, you need leading zeroes, because <code>toString(16)</code> will return <code>f</code> for <code>15</code>, instead of <code>00000f</code>. Usually I will use the loop like this:</p>
  
  <pre><code>var s = X.toString(16); while (s.length &lt; 6) s = '0' + s
  </code></pre>
  
  <p>is there a better way in JavaScript?</p>
  
  <p>UPD: The answer <a href="https://stackoverflow.com/questions/1267283/how-can-i-create-a-zerofilled-value-using-javascript">suggested answer  How can I create a Zerofilled value using JavaScript? </a> is not what I am looking for, I look for a very short code, that is suited specifically for 24 bit integers converted to a hexadecimal looking strings.</p>