time-to-botec/squiggle/node_modules/@stdlib/assert/is-inherited-property
NunoSempere b6addc7f05 feat: add the node modules
Necessary in order to clearly see the squiggle hotwiring.
2022-12-03 12:44:49 +00:00
..
docs feat: add the node modules 2022-12-03 12:44:49 +00:00
lib feat: add the node modules 2022-12-03 12:44:49 +00:00
package.json feat: add the node modules 2022-12-03 12:44:49 +00:00
README.md feat: add the node modules 2022-12-03 12:44:49 +00:00

isInheritedProperty

Test if an object has an inherited property.

Usage

var isInheritedProperty = require( '@stdlib/assert/is-inherited-property' );

isInheritedProperty( value, property )

Returns a boolean indicating if a value has an inherited property.

var obj = {
    'beep': 'boop'
};

var bool = isInheritedProperty( obj, 'beep' );
// returns false

bool = isInheritedProperty( obj, 'hasOwnProperty' );
// returns true

bool = isInheritedProperty( obj, 'bap' );
// returns false

Notes

  • The function does not throw when provided null or undefined. Instead, the function returns false.

    var bool = isInheritedProperty( null, 'a' );
    // returns false
    
    bool = isInheritedProperty( void 0, 'a' );
    // returns false
    
  • Value arguments other than null or undefined are coerced to objects.

    var bool = isInheritedProperty( 'beep', 'toString' );
    // returns true
    
  • Non-symbol property arguments are coerced to strings.

    function Foo() {
        return this;
    }
    
    Foo.prototype.null = true;
    Foo.prototype[ '[object Object]' ] = true;
    
    var obj = new Foo();
    
    var bool = isInheritedProperty( obj, null );
    // returns true
    
    bool = isInheritedProperty( obj, {} );
    // returns true
    

Examples

var isInheritedProperty = require( '@stdlib/assert/is-inherited-property' );

var bool = isInheritedProperty( {}, 'hasOwnProperty' );
// returns true

bool = isInheritedProperty( { 'a': 'b' }, 'a' );
// returns false

bool = isInheritedProperty( { 'a': 'b' }, 'c' );
// returns false

bool = isInheritedProperty( { 'a': 'b' }, null );
// returns false

bool = isInheritedProperty( null, 'a' );
// returns false

bool = isInheritedProperty( void 0, 'a' );
// returns false

bool = isInheritedProperty( { 'null': false }, null );
// returns false

bool = isInheritedProperty( { '[object Object]': false }, {} );
// returns false