var SomeValue = "100";
var SomeNumber = 3;
// alert 1: "1003"
alert( SomeValue + SomeNumber);
// alert 2: "103"
alert( Number(SomeValue) + SomeNumber);
So this is where we can get a way with telling people 1 * 1 may not always equal 2... in this sample the first alert is going to make everything a string where as in the next one we cast the questionable value to a Number and now the math works right...
hmmm... whats the point of a varient if it can't figure out its a number.
This blog has moved…
6 years ago