title: Converting a hex string into a BYTE array JS
body: <p>I have been at this for a bit, and I am new to programing with JS.  I am making a game using JS, HTML5, node and socket.io.  I am working on the protocol right now and I am sending the server strings that are hex.</p>
  
  <p>An example of a string would be: 00010203040506070809</p>
  
  <p>I am having a hard time converting it to: 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09</p>
  
  <p>What I plan on doing is taking these custom packets and having a switch on my server based on the packets.  So for example:</p>
  
  <pre><code>BYTE HEADER | + Packet
  0x00        | 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09
  </code></pre>
  
  <p>Then I call: parsepacket(header, data, len);</p>
  
  <pre><code>function parsepacket(header, data, len){
  switch(header)
  {
  case '0x00':    // not hexed
  console.log('The client wants to connect');
  // Do some stuff to connect
  break;
  
  case '0x01':
  console.log('0x01');
  break;
  
  case '0x02':
  console.log('0x02!');
  break;
  }
  };
  </code></pre>
  
  <p>Does anyone know how to do this?</p>