I'm pretty new to javascript but it seems like typeof(blah)
lets you check if something is a number (it doesn't say true for strings). A know the OP asked for strings + numbers but I thought this might be worth documenting for other people.
eg:
function isNumeric(something){
return typeof(something) === 'number';
}
Here are the docs
and here's a few console runs of what typeof produces:
typeof(12);
"number"
typeof(null);
"object"
typeof('12');
"string"
typeof(12.3225);
"number"
one slight weirdness I am aware of is
typeof(NaN);
"number"
but it wouldn't be javascript without something like that right?!