I wrote this function some time ago to find out if a variable is numeric, regardless of its type. The variable could be a String that contains numeric value.
function isNumber(n) { return !isNaN(parseFloat(n)) && isFinite(n); }