isNumberArray

Test if a value is an array-like object of numbers.

Usage

var isNumberArray = require( '@stdlib/assert/is-number-array' );

isNumberArray( value )

Tests if a value is an array-like object of numbers.

var bool = isNumberArray( [ 1, 2, 3, 4 ] );
// returns true

isNumberArray.primitives( value )

Tests if a value is an array-like object containing only number primitives.

var Number = require( '@stdlib/number/ctor' );

var bool = isNumberArray.primitives( [ 1, 2, 3 ] );
// returns true

bool = isNumberArray.primitives( [ 1, new Number( 2 ), 3 ] );
// returns false

isNumberArray.objects( value )

Tests if a value is an array-like object containing only Number objects.

var Number = require( '@stdlib/number/ctor' );

var bool = isNumberArray.objects( [ new Number( 1 ), new Number( 2 ) ] );
// returns true

bool = isNumberArray.objects( [ new Number( 1 ), 2 ] );
// returns false

Examples

var Number = require( '@stdlib/number/ctor' );
var isNumberArray = require( '@stdlib/assert/is-number-array' );

var bool = isNumberArray( [ 3.14 ] );
// returns true

bool = isNumberArray( [ NaN ] );
// returns true

bool = isNumberArray( [ 1, 2, 3 ] );
// returns true

bool = isNumberArray( [ new Number( 3.14 ), 2, 3 ] );
// returns true

bool = isNumberArray( 3.14 );
// returns false

bool = isNumberArray( [] );
// returns false

bool = isNumberArray( [ '1', 2 ] );
// returns false
Did you find this page helpful?