@stdlib/assert-is-number
v0.2.2
Published
Test if a value is a number.
Downloads
1,779,696
Readme
isNumber
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 );
// returns true
bool = isNumber( new Number( 3.14 ) );
// returns true
bool = isNumber( NaN );
// returns true
bool = isNumber( null );
// returns false
isNumber.isPrimitive( value )
Tests if a value
is a primitive number
.
var Number = require( '@stdlib/number-ctor' );
var bool = isNumber.isPrimitive( 3.14 );
// returns true
bool = isNumber.isPrimitive( NaN );
// returns true
bool = isNumber.isPrimitive( new Number( 3.14 ) );
// returns false
isNumber.isObject( value )
Tests if a value
is a Number
object.
var Number = require( '@stdlib/number-ctor' );
var bool = isNumber.isObject( 3.14 );
// returns false
bool = isNumber.isObject( new Number( 3.14 ) );
// returns true
Examples
var Number = require( '@stdlib/number-ctor' );
var isNumber = require( '@stdlib/assert-is-number' );
var bool = isNumber( 5 );
// returns true
bool = isNumber( new Number( 5 ) );
// returns true
bool = isNumber( NaN );
// returns true
bool = isNumber( '5' );
// returns false
bool = isNumber( null );
// returns false
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.