hasEqualValues

Test if two arrays have equal values.

Usage

var hasEqualValues = require( '@stdlib/array/base/assert/has-equal-values' );

hasEqualValues( x, y )

Tests if two arrays have equal values.

var x = [ 0, 0, 1, 0 ];
var y = [ 0, 0, 1, 0 ];

var bool = hasEqualValues( x, y );
// returns true

Notes

  • If provided arrays of unequal length, the function returns false.
  • The function performs strict equality comparison.
  • 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 hasEqualValues = require( '@stdlib/array/base/assert/has-equal-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 = hasEqualValues( x, y );
// returns true
Did you find this page helpful?