@stdlib/assert-is-same-value-zero
    TypeScript icon, indicating that this package has built-in type declarations

    0.0.7 • Public • Published

    isSameValueZero

    NPM version Build Status Coverage Status

    Test if two arguments are the same value.

    Installation

    npm install @stdlib/assert-is-same-value-zero

    Usage

    var isSameValueZero = require( '@stdlib/assert-is-same-value-zero' );

    isSameValueZero( a, b )

    Tests if two arguments a and b are the same value.

    var bool = isSameValueZero( false, false );
    // returns true
    
    bool = isSameValueZero( '', '' );
    // returns true
    
    bool = isSameValueZero( {}, {} );
    // returns false

    In contrast to the strict equality operator ===, the function treats NaNs as the same value.

    var bool = ( NaN === NaN );
    // returns false
    
    bool = isSameValueZero( NaN, NaN );
    // returns true

    In contrast to the SameValue Algorithm, the function does not distinguish between +0 and -0.

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

    Examples

    var isSameValueZero = require( '@stdlib/assert-is-same-value-zero' );
    
    var bool = isSameValueZero( true, true );
    // returns true
    
    bool = isSameValueZero( true, false );
    // returns false
    
    bool = isSameValueZero( 'beep', 'beep' );
    // returns true
    
    bool = isSameValueZero( 3.14, 3.14 );
    // returns true
    
    bool = isSameValueZero( null, null );
    // returns true
    
    bool = isSameValueZero( 0.0, 0.0 );
    // returns true
    
    bool = isSameValueZero( -0.0, 0.0 );
    // returns true
    
    bool = isSameValueZero( NaN, NaN );
    // returns true
    
    bool = isSameValueZero( {}, {} );
    // returns false
    
    bool = isSameValueZero( [], [] );
    // returns false
    
    bool = isSameValueZero( isSameValueZero, isSameValueZero );
    // 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-2022. The Stdlib Authors.

    Install

    npm i @stdlib/assert-is-same-value-zero

    Homepage

    stdlib.io

    DownloadsWeekly Downloads

    44

    Version

    0.0.7

    License

    Apache-2.0

    Unpacked Size

    38.7 kB

    Total Files

    9

    Last publish

    Collaborators

    • stdlib-bot
    • kgryte
    • planeshifter
    • rreusser