function includesAny
includesAny(
searchIn: string | string[] | null | undefined,
searchFor: string | string[] | null | undefined
): boolean

Determines if searchIn contains any of the given searchFor term(s).

When searchIn is a string, this performs a substring check. When searchIn is a list, this performs an element check. When searchFor is a list, at least one item must be found.

Examples

Example 1

includesAny("hello world", "hello"); // true
includesAny("hello world", ["hello", "moon"]); // true
includesAny("hello world", ["sun", "moon"]); // false
includesAny(["a", "b", "c"], "a"); // true
includesAny(["a", "b", "c"], ["a", "d"]); // true
includesAny(["a", "b", "c"], ["d", "e"]); // false
includesAny("hello world", []); // false
includesAny(null, "hello"); // false
includesAny("hello world", undefined); // false

Parameters

searchIn: string | string[] | null | undefined
searchFor: string | string[] | null | undefined

Return Type

boolean

Usage

import { includesAny } from ".";