JS Utils Kit - v0.5.1
    Preparing search index...

    Function isNumericString

    • 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.
      isNumericString("42"); // true
      isNumericString("-3.14"); // true
      isNumericString("1e5"); // true
      isNumericString(" 123 "); // true
      isNumericString("123abc"); // false
      isNumericString("abc123"); // false

      See also: