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

    Function isString

    • Determines whether the provided value is a string.

      This function returns true if the input is a non-null, non-undefined primitive string. It acts as a type guard, so TypeScript will narrow the type to string when used in conditionals.

      Type Parameters

      • T

        The type of the input value.

      Parameters

      • value: T

        The value to be checked.

      Returns boolean

      • Whether the value is a string (true) or not (false).
      isString("hello"); // true
      isString(123); // false
      isString(null); // false
      isString(undefined); // false

      const value: unknown = "test";
      if (isString(value)) {
      console.log(value.toUpperCase());
      }