It's been a while since I wrote a good entry, but this one was particularly worthy of posting! I was trying to find out how to check if a variable is an integer (or if a variable is not an integer) in javascript! Welp, after reading through a wide variety of mind bendingly complex solutions, the simplest one came up...
The solution is .isNaN() . You can use this to check if something is NOT a number, and by sheer virtue If Else, if it is not a number, the else IS if it's a number.
var test1="500";
var test2="something interesting";
alert(isNaN(test1));
alert(isNaN(test2));
Post new comment