isNumber
![dependencies](https://img.shields.io/david/stdlib-js/assert-is-number)
Test if a value is a number.
Installation
npm install @stdlib/assert-is-number
Usage
var isNumber = require( '@stdlib/assert-is-number' );
isNumber( value )
Tests if a value
is a number
.
var Number = require( '@stdlib/number-ctor' );
var bool = isNumber( 3.14 );
bool = isNumber( new Number( 3.14 ) );
bool = isNumber( NaN );
bool = isNumber( null );
isNumber.isPrimitive( value )
Tests if a value
is a primitive number
.
var Number = require( '@stdlib/number-ctor' );
var bool = isNumber.isPrimitive( 3.14 );
bool = isNumber.isPrimitive( NaN );
bool = isNumber.isPrimitive( new Number( 3.14 ) );
isNumber.isObject( value )
Tests if a value
is a Number
object.
var Number = require( '@stdlib/number-ctor' );
var bool = isNumber.isObject( 3.14 );
bool = isNumber.isObject( new Number( 3.14 ) );
Examples
var Number = require( '@stdlib/number-ctor' );
var isNumber = require( '@stdlib/assert-is-number' );
var bool = isNumber( 5 );
bool = isNumber( new Number( 5 ) );
bool = isNumber( NaN );
bool = isNumber( '5' );
bool = isNumber( null );
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.
License
See LICENSE.
Copyright
Copyright © 2016-2021. The Stdlib Authors.