title: Getting r, g and b from hex
body: <p>I have a hexadecimal color code.
  How do I get value of r, g and b from it in javascript.
  I tried many but none worked and I got errors.
  Here is one of those which I tried</p>
  <pre><code>function cutHex(h) {return (h[0]==&quot;#&quot;) ? h.substring(1,7):h}
  function hexToR(h) {return parseInt((cutHex(h)).substring(0,2),16)}
  function hexToG(h) {return parseInt((cutHex(h)).substring(2,4),16)}
  function hexToB(h) {return parseInt((cutHex(h)).substring(4,6),16)}
  </code></pre>
  <p>It give error</p>
  <pre><code>Uncaught TypeError: cutHex(...).substring is not a function
  </code></pre>