@stdlib/assert-is-primitive-array
v0.2.2
Published
Test if a value is an array-like object containing only JavaScript primitives.
Downloads
13
Readme
isPrimitiveArray
Test if a value is an array-like object containing only JavaScript primitives.
Installation
npm install @stdlib/assert-is-primitive-array
Usage
var isPrimitiveArray = require( '@stdlib/assert-is-primitive-array' );
isPrimitiveArray( value )
Tests if a value
is an array-like object containing only JavaScript primitives.
var bool = isPrimitiveArray( [ '3', 2, null ] );
// returns true
bool = isPrimitiveArray( [ {}, 2, 1 ] );
// returns false
bool = isPrimitiveArray( [ new String( 'abc' ), '3.0' ] );
// returns false
Examples
var Number = require( '@stdlib/number-ctor' );
var isPrimitiveArray = require( '@stdlib/assert-is-primitive-array' );
var bool = isPrimitiveArray( [ '3', 2, null ] );
// returns true
bool = isPrimitiveArray( [ void 0, true ] );
// returns true
bool = isPrimitiveArray( [ new String( 'abc' ), false ] );
// returns false
bool = isPrimitiveArray( [ new Number( 2 ), null ] );
// returns false
bool = isPrimitiveArray( [ function noop() {}, null ] );
// returns false
See Also
@stdlib/assert-is-array
: test if a value is an array.@stdlib/assert-is-primitive
: test if a value is a JavaScript primitive.
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.