I\'m doing some trouble-shooting and want to add a check that a parameter to a function is a number. How do I do this?
Something like this...
function fn
function fn(id) { var x = /^(\+|-)?\d+$/; if (x.test(id)) { //integer return true; } else { //not an integer return false; } }
Test fiddle: http://jsfiddle.net/xLYW7/