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
typeofoperator to determine the type of each argument. - The function returns
trueif the types are the same andfalseotherwise.
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
@stdlib/assert/is-same-native-class: test if two arguments have the same native class.@stdlib/assert/is-same-value: test if two arguments are the same value.@stdlib/assert/is-strict-equal: test if two arguments are strictly equal.