@stdlib/array-base-any-is-entry
v0.1.1
Published
Test whether at least one element in a provided array has a specified own property key-value pair.
Readme
anyIsEntry
Test whether at least one element in a provided array has a specified own property key-value pair.
Installation
npm install @stdlib/array-base-any-is-entryUsage
var anyIsEntry = require( '@stdlib/array-base-any-is-entry' );anyIsEntry( arr, property, value )
Tests whether at least one element in a provided array has a specified own property key-value pair.
var o1 = {
'a': 1
};
var o2 = {
'b': 2
};
var o3 = {
'c': 3
};
var bool = anyIsEntry( [ o1, o2, o3 ], 'b', 2 );
// returns true
bool = anyIsEntry( [ o1, o2, o3 ], 'd', 0 );
// returns false
bool = anyIsEntry( [ o1, o2, o3 ], 'b', 0 );
// returns falseExamples
var fromCodePoint = require( '@stdlib/string-from-code-point' );
var discreteUniform = require( '@stdlib/random-base-discrete-uniform' );
var filledBy = require( '@stdlib/array-filled-by' );
var anyIsEntry = require( '@stdlib/array-base-any-is-entry' );
function randomObject() {
var o = {};
o[ fromCodePoint( 97+discreteUniform( 0, 25 ) ) ] = 0;
return o;
}
var arr = filledBy( 10, 'generic', randomObject );
console.log( arr );
var bool = anyIsEntry( arr, 'a', 0 );
console.log( 'a: %s', bool );
bool = anyIsEntry( arr, 'b', 0 );
console.log( 'b: %s', bool );Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2026. The Stdlib Authors.
