title: How can I convert a string into a unicode character?
body: <p>In Javascript <code>'\uXXXX'</code> returns in a unicode character. But how can I get a unicode character when the <code>XXXX</code> part is a variable?</p>
  
  <p>For example:</p>
  
  <pre><code>var input = '2122';
  console.log('\\u' + input);             // returns a string: "\u2122"
  console.log(new String('\\u' + input)); // returns a string: "\u2122"
  </code></pre>
  
  <p>The only way I can think of to make it work, is to use <code>eval</code>; yet I hope there's a better solution:</p>
  
  <pre><code>var input = '2122';
  var char = '\\u' + input;
  console.log(eval("'" + char + "'"));    // returns a character: "™"
  </code></pre>