Function strContains

  • The strContains() method performs a case-sensitive search to determine whether one string may be found within another string, returning true or false as appropriate.

    This method lets you determine whether or not a string includes another string.

    Parameters

    • value: string

      The string value to be searched.

    • searchString: string

      A string to be searched for within the value. Cannot be a regex. All values that are not regexes are coerced to strings, so omitting it or passing undefined causes strContains() to search for the string "undefined", which is rarely what you want.

    • Optional position: number

      The position within the string at which to begin searching for searchString. (Defaults to 0.)

    Returns boolean

    true if the search string is found anywhere within the given string value, including when searchString is an empty string; otherwise, false.

    Since

    0.9.0

    Throws

    TypeError If searchString is a regex.