@nevware21/ts-utils
    Preparing search index...

    Function isStringLike

    • Checks if the value is a string, either a primitive string (see isString) or a String object (see isStringObject), eg. "abc", new String("abc") or Object("abc"). A String object has the length, indexes and functions of its string but it is still an object, so use asString (or value.valueOf()) to get the primitive string when one is needed, eg. to compare it using === or to use it as a Map key.

      Parameters

      • value: any

        The value to check

      Returns value is string | String

      True if the value is a primitive string or a String object, otherwise false

      0.20.0

      isStringLike("");                        // true
      isStringLike("abc"); // true
      isStringLike(String("abc")); // true
      isStringLike(new String("")); // true
      isStringLike(Object("abc")); // true

      isStringLike(null); // false
      isStringLike(undefined); // false
      isStringLike(0); // false
      isStringLike(["a", "b", "c"]); // false
      isStringLike({ length: 1, 0: "a" }); // false (an array-like object)
      isStringLike({ toString: () => "abc" }); // false (an object which converts to a string)