Possible Duplicate:
How do I Convert a String into an Integer in JavaScript?
Given the following code:
var n = '1';
var x = n + 2;
x is set to "12".
Assuming I cannot change the value of n, what the most efficient way to have x set to 3?
Is it necessary to use parseInt() here? Or is there a way to have JavaScript automatically treat the digit as a number?
 
     
     
    