isSameType
Test if two arguments have the 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 andfalse
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