Checks whether a given string represents a valid numeric value.
This function attempts to convert the input string to a number using
both Number() and parseFloat(). It returns true only if both
conversions do not result in NaN, ensuring that the input is
a fully numeric string.
Accepts integers, decimals, scientific notation (e.g. "1e5"), and
ignores surrounding whitespace. Does not allow trailing or embedded characters
like "123abc" or "abc123".
Parameters
value: string
The string to validate.
Returns boolean
true if the string represents a valid number; otherwise, false.
Checks whether a given string represents a valid numeric value.
This function attempts to convert the input string to a number using both
Number()
andparseFloat()
. It returnstrue
only if both conversions do not result inNaN
, ensuring that the input is a fully numeric string.Accepts integers, decimals, scientific notation (e.g. "1e5"), and ignores surrounding whitespace. Does not allow trailing or embedded characters like "123abc" or "abc123".