Checks whether an element in a collection passes a test.
Checks whether an element in a collection passes a test.
Checks whether an element in a collection passes a test.
Checks whether an element in a collection passes a test.
Finds elements in an array-like object that satisfy a test condition.
object from which elements will be tested
function invoked for each array element. If the return value is truthy, the value is considered to have satisfied the test condition.
array of indices, element values, or arrays of index-value pairs
var data = [ 30, 20, 50, 60, 10 ];
var vals = find( data, condition );
// returns [ 0, 2, 3 ]
function condition( val ) {
return val > 20;
}
var data = [ 30, 20, 50, 60, 10 ];
var vals = find( data, condition );
// returns []
function condition( val ) {
return val > 1000;
}
Finds elements in an array-like object that satisfy a test condition.
object from which elements will be tested
function options
function invoked for each array element. If the return value is truthy, the value is considered to have satisfied the test condition.
array of indices, element values, or arrays of index-value pairs
var data = [ 30, 20, 50, 60, 10 ];
var opts = {
'k': 2,
'returns': 'values'
};
var vals = find( data, opts, condition );
// returns [ 30, 50 ]
function condition( val ) {
return val > 20;
}
var data = [ 30, 20, 50, 60, 10 ];
var opts = {
'k': -2,
'returns': 'values'
};
var vals = find( data, opts, condition );
// returns [ 60, 50 ]
function condition( val ) {
return val > 20;
}
var data = [ 30, 20, 50, 60, 10 ];
var opts = {
'k': -2,
'returns': '*'
};
var vals = find( data, opts, condition );
// returns [ [3, 60], [2, 50] ]
function condition( val ) {
return val > 20;
}
Checks whether an element in a collection passes a test.
collection value
collection index
boolean indicating whether an element in a collection passes a test