NewDash

    Function find

    • Iterates over elements of collection, returning the first element predicate returns truthy for. The predicate is invoked with three arguments: (value, index|key, collection).

      Type Parameters

      • T

      Parameters

      • collection: ArrayLike<T>

        The collection to inspect.

      • predicate: (item: T) => boolean

        function invoked per iteration.

      • OptionalfromIndex: number

        The index to search from.

      Returns T

      Returns the first matched element, else undefined.

      5.2.0

      var users = [
      { 'user': 'barney', 'age': 36, 'active': true },
      { 'user': 'fred', 'age': 40, 'active': false },
      { 'user': 'pebbles', 'age': 1, 'active': true }
      ];

      find(users, function(o) { return o.age < 40; });
      // => object for 'barney'

      // The `matches` iteratee shorthand.
      find(users, { 'age': 1, 'active': true });
      // => object for 'pebbles'

      // The `matchesProperty` iteratee shorthand.
      find(users, ['active', false]);
      // => object for 'fred'

      // The `property` iteratee shorthand.
      find(users, 'active');
      // => object for 'barney'
    • Iterates over elements of collection, returning the first element predicate returns truthy for. The predicate is invoked with three arguments: (value, index|key, collection).

      Type Parameters

      • T

      Parameters

      • collection: ArrayLike<T>

        The collection to inspect.

      • predicate: Partial<T>

        function invoked per iteration.

      • OptionalfromIndex: number

        The index to search from.

      Returns T

      Returns the first matched element, else undefined.

      5.2.0

      var users = [
      { 'user': 'barney', 'age': 36, 'active': true },
      { 'user': 'fred', 'age': 40, 'active': false },
      { 'user': 'pebbles', 'age': 1, 'active': true }
      ];

      find(users, function(o) { return o.age < 40; });
      // => object for 'barney'

      // The `matches` iteratee shorthand.
      find(users, { 'age': 1, 'active': true });
      // => object for 'pebbles'

      // The `matchesProperty` iteratee shorthand.
      find(users, ['active', false]);
      // => object for 'fred'

      // The `property` iteratee shorthand.
      find(users, 'active');
      // => object for 'barney'
    • Iterates over elements of collection, returning the first element predicate returns truthy for. The predicate is invoked with three arguments: (value, index|key, collection).

      Type Parameters

      • T

      Parameters

      • collection: ArrayLike<T>

        The collection to inspect.

      • predicate: (boolean | keyof T)[]

        function invoked per iteration.

      • OptionalfromIndex: number

        The index to search from.

      Returns T

      Returns the first matched element, else undefined.

      5.2.0

      var users = [
      { 'user': 'barney', 'age': 36, 'active': true },
      { 'user': 'fred', 'age': 40, 'active': false },
      { 'user': 'pebbles', 'age': 1, 'active': true }
      ];

      find(users, function(o) { return o.age < 40; });
      // => object for 'barney'

      // The `matches` iteratee shorthand.
      find(users, { 'age': 1, 'active': true });
      // => object for 'pebbles'

      // The `matchesProperty` iteratee shorthand.
      find(users, ['active', false]);
      // => object for 'fred'

      // The `property` iteratee shorthand.
      find(users, 'active');
      // => object for 'barney'
    • Iterates over elements of collection, returning the first element predicate returns truthy for. The predicate is invoked with three arguments: (value, index|key, collection).

      Type Parameters

      • T

      Parameters

      • collection: ArrayLike<T>

        The collection to inspect.

      • predicate: keyof T

        function invoked per iteration.

      • OptionalfromIndex: number

        The index to search from.

      Returns T

      Returns the first matched element, else undefined.

      5.2.0

      var users = [
      { 'user': 'barney', 'age': 36, 'active': true },
      { 'user': 'fred', 'age': 40, 'active': false },
      { 'user': 'pebbles', 'age': 1, 'active': true }
      ];

      find(users, function(o) { return o.age < 40; });
      // => object for 'barney'

      // The `matches` iteratee shorthand.
      find(users, { 'age': 1, 'active': true });
      // => object for 'pebbles'

      // The `matchesProperty` iteratee shorthand.
      find(users, ['active', false]);
      // => object for 'fred'

      // The `property` iteratee shorthand.
      find(users, 'active');
      // => object for 'barney'
    MMNEPVFCICPMFPCPTTAAATR