title: How to convert a String to Bytearray
body: <p>How can I convert a string in bytearray using JavaScript. Output should be equivalent of the below C# code.</p>
  
  <pre><code>UnicodeEncoding encoding = new UnicodeEncoding();
  byte[] bytes = encoding.GetBytes(AnyString);
  </code></pre>
  
  <p>As UnicodeEncoding is by default of UTF-16 with Little-Endianness.</p>
  
  <p><strong>Edit:</strong> I have a requirement to match the bytearray generated client side with the one generated at server side using the above C# code.</p>