0.2.1 • Published 3 months ago

@stdlib/assert-is-same-type v0.2.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
3 months ago

isSameType

NPM version Build Status Coverage Status

Test if two arguments have the same type.

Installation

npm install @stdlib/assert-is-same-type

Usage

var isSameType = require( '@stdlib/assert-is-same-type' );

isSameType( a, b )

Tests if two arguments a and b have the same type.

var bool = isSameType( false, true );
// returns true

bool = isSameType( 'beep', 'boop' );
// returns true

bool = isSameType( 0.0, '0.0' );
// returns false

Notes

  • The function uses the typeof operator to determine the type of each argument.
  • The function returns true if the types are the same and false otherwise.

Examples

var isSameType = require( '@stdlib/assert-is-same-type' );

var bool = isSameType( true, false );
// returns true

bool = isSameType( 3.14, -3.14 );
// returns true

bool = isSameType( {}, [] );
// returns true

bool = isSameType( null, null );
// returns true

bool = isSameType( NaN, NaN );
// returns true

bool = isSameType( null, NaN );
// returns false

bool = isSameType( 0.0, '0.0' );
// returns false

See Also


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

Chat


License

See LICENSE.

Copyright

Copyright © 2016-2024. The Stdlib Authors.