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 […]
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Apr | ||||||
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 | 30 | 31 | |