0.2.1 • Published 2 months ago

@stdlib/assert-is-strict-equal v0.2.1

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

isStrictEqual

NPM version Build Status Coverage Status

Test if two arguments are strictly equal.

Installation

npm install @stdlib/assert-is-strict-equal

Usage

var isStrictEqual = require( '@stdlib/assert-is-strict-equal' );

isStrictEqual( a, b )

Tests if two arguments a and b are strictly equal.

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

bool = isStrictEqual( '', '' );
// returns true

bool = isStrictEqual( {}, {} );
// returns false

bool = isStrictEqual( NaN, NaN );
// returns false

In contrast to the strict equality operator ===, the function distinguishes between +0 and -0.

var bool = ( 0.0 === -0.0 );
// returns true

bool = isStrictEqual( 0.0, -0.0 );
// returns false

bool = isStrictEqual( -0.0, -0.0 );
// returns true

Examples

var isStrictEqual = require( '@stdlib/assert-is-strict-equal' );

var bool = isStrictEqual( true, true );
// returns true

bool = isStrictEqual( true, false );
// returns false

bool = isStrictEqual( 'beep', 'beep' );
// returns true

bool = isStrictEqual( 3.14, 3.14 );
// returns true

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

bool = isStrictEqual( 0.0, 0.0 );
// returns true

bool = isStrictEqual( -0.0, 0.0 );
// returns false

bool = isStrictEqual( NaN, NaN );
// returns false

bool = isStrictEqual( {}, {} );
// returns false

bool = isStrictEqual( [], [] );
// returns false

bool = isStrictEqual( isStrictEqual, isStrictEqual );
// returns true

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.