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

    Function arrContains

    • The arrContains() method determines whether an array contains a certain value among its entries, returning true or false as appropriate.

      Type Parameters

      • T

      Parameters

      • theArray: ArrayLike<T>

        The array or array like object of elements to be searched.

      • searchElement: T

        The value to search for

      • OptionalfromIndex: number

        The optional Zero-based index at which to start searching, converted to an integer.

        • Negative index counts back from the end of the array — if fromIndex < 0, fromIndex + array.length is used. However, the array is still searched from front to back in this case.
        • If fromIndex < -array.length or fromIndex is omitted, 0 is used, causing the entire array to be searched.
        • If fromIndex >= array.length, the array is not searched and false is returned.

      Returns boolean

      A boolean value which is true if the value searchElement is found within the array (or the part of the array indicated by the index fromIndex, if specified).

      0.8.0

      arrContains([1, 2, 3], 2);       // true
      arrContains([1, 2, 3], 4); // false
      arrContains([1, 2, 3], 3, 3); // false
      arrContains([1, 2, 3], 3, -1); // true
      arrContains([1, 2, NaN], NaN); // true
      arrContains(["1", "2", "3"], 3 as any); // false

      // Array Like
      arrContains({ length: 3, 0: 1, 1: 2, 2: 3 }, 2); // true
      arrContains({ length: 3, 0: 1, 1: 2, 2: 3 }, 4); // false
      arrContains({ length: 3, 0: 1, 1: 2, 2: 3 }, 3, 3); // false
      arrContains({ length: 3, 0: 1, 1: 2, 2: 3 }, 3, -1); // true
      arrContains({ length: 3, 0: 1, 1: 2, 2: NaN }, NaN); // true
      arrContains({ length: 3, 0: "1", 1: "2", 2: "3" }, 3 as any); // false