First, the code above would return true if the argument was an array of length 1, and that single element was of a type deemed as numeric by the above logic. This one takes most of what has already been mentioned into consideration, but includes hex and octal numbers, negative scientific, Infinity and has removed decimal scientific (4e3.2 is not valid).
Would you like to answer one of these unanswered questions instead?
// Whitespace strings: Is Numeric(' ') == true; Is Numeric('\t\t') == true; Is Numeric('\n\r') == true; // Number literals: Is Numeric(-1) == false; Is Numeric(0) == false; Is Numeric(1.1) == false; Is Numeric(8e5) == false; Arrrgh! Reg Ex is icky for this, and I'm not talking just performance.
It's so easy to make subtle, impossible to spot mistakes with your regular expression.
There is also a post on stackoverflow that has been widely accepted as the answer, the same general routine that the afore mentioned libraries are using. It works with numeric strings as well as plain numbers. Positive oct numbers start with 0 and negative oct numbers start with -0.
Top five features in Java Script ES6 Worth Mastering Java Script ES6 adds a slew of new features to the Java Script language, some more groundbreaking and widely applicable than others.