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
function condition( val ) {
return val > 20;
}
var data = [ 30, 20, 50, 60, 10 ];
var vals = find( data, condition );
// returns [ 0, 2, 3 ]
function condition( val ) {
return val > 1000;
}
var data = [ 30, 20, 50, 60, 10 ];
var vals = find( data, condition );
// returns []
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
function condition( val ) {
return val > 20;
}
var data = [ 30, 20, 50, 60, 10 ];
var opts = {
'k': 2,
'returns': 'indices'
};
var vals = find( data, opts, condition );
// returns [ 0, 2 ]
function condition( val ) {
return val > 20;
}
var data = [ 30, 20, 50, 60, 10 ];
var opts = {
'k': -2,
'returns': 'indices'
};
var vals = find( data, opts, condition );
// returns [ 3, 2 ]
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 values
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 [ 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 ]
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 index-value pairs
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] ]
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