title: Convert two bytes into signed 16 bit integer in JavaScript
body: <p>In JavaScript, I need to convert two bytes into a 16 bit integer, so that I can convert a stream of audio data into an array of signed PCM values.</p>
  
  <p>Most answers online for converting bytes to 16 bit integers use the following, but it does not work correctly for negative numbers.</p>
  
  <pre><code>var result = (((byteA &amp; 0xFF) &lt;&lt; 8) | (byteB &amp; 0xFF));
  </code></pre>