Treat Digit as Number
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/1133770/how-do-i-convert-a-string-into-an-integer-in-javascript">How do I Convert a String into an Integer in JavaScript?</a>  </p>
</blockquote>



<p>Given the following code:</p>

<pre><code>var n = '1';
var x = n + 2;
</code></pre>

<p><code>x</code> is set to "12".</p>

<p>Assuming I cannot change the value of <code>n</code>, what the most efficient way to have <code>x</code> set to 3?</p>

<p>Is it necessary to use <code>parseInt()</code> here? Or is there a way to have JavaScript automatically treat the digit as a number?</p>
