every
Test whether all elements in an array are truthy.
Usage
var every = require( '@stdlib/array/base/every' );
every( x )
Tests whether all elements in an array are truthy.
var x = [ 1, 2, 3, 4 ];
var bool = every( x );
// returns true
Notes
- If provided an empty array, the function returns
true
. - The function does not skip
undefined
elements and is thus not optimized for sparse arrays.
Examples
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var every = require( '@stdlib/array/base/every' );
var x = discreteUniform( 10, 0, 10, {
'dtype': 'int32'
});
// returns <Int32Array>
var out = every( x );
// returns <boolean>