30 Jan
Posted by krisgale as javascript, annoyances, browsers
here’s an interesting javascript ‘gotcha’… this block of code:
var y = 37;
var x = parseInt(y,10);
var s = “37″;
alert(x === s);
gives you a “false” alert box, whereas this:
var y = 37;
var x = “” + parseInt(y,10);
var s = “37″;
alert(x === s);
yields “true.”
apparently, ‘x’ is not able to be compared to other strings until it is concatenated […]