@stdlib/array-base-assert-has-same-values
v0.3.0
Published
Test if two arrays have the same values.
Downloads
104
Readme
hasSameValues
Test if two arrays have the same values.
Installation
npm install @stdlib/array-base-assert-has-same-values
Usage
var hasSameValues = require( '@stdlib/array-base-assert-has-same-values' );
hasSameValues( x, y )
Tests if two arrays have the same values.
var x = [ 0, 0, 1, 0 ];
var y = [ 0, 0, 1, 0 ];
var bool = hasSameValues( x, y );
// returns true
Notes
- If provided arrays of unequal length, the function returns
false
. - 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 Complex128Array = require( '@stdlib/array-complex128' );
var hasSameValues = require( '@stdlib/array-base-assert-has-same-values' );
var buf = discreteUniform( 10, 0, 10 );
// returns <Float64Array>
var x = new Complex128Array( buf );
// returns <Complex128Array>
var y = new Complex128Array( buf );
// returns <Complex128Array>
var out = hasSameValues( x, y );
// returns true
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-2024. The Stdlib Authors.