Skip to content

Mint.utils.arrayFirst

Tania Shatilova edited this page Nov 10, 2015 · 1 revision

The arrayFirst() method returns the first item of an array that is matched the predicate function.

Syntax

var first = Mint.utils.arrayFirst(array, predicate);

Parameters

  • array - array in which item is searching.
  • predicate - (function) function that returns true for searching item.

Return Value

The first item of an array that is matched the predicate function; null if item is not found.

Examples

var array = [1, 3, 8];
var first = Mint.utils.arrayFirst(array, function (item){
    return item > 2;
});
// first equal 3

first = Mint.utils.arrayFirst(array, function (item){
    return item > 10;
});
// first is null

Clone this wiki locally