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

2.6 KiB

isNonConfigurableProperty

Test if an object's own property is non-configurable.

Usage

var isNonConfigurableProperty = require( '@stdlib/assert/is-nonconfigurable-property' );

isNonConfigurableProperty( value, property )

Returns a boolean indicating if a value has a non-configurable property (i.e., a property which cannot be deleted and whose descriptor cannot be changed).

var defineProperty = require( '@stdlib/utils/define-property' );

var obj = {
    'foo': 'bar'
};

defineProperty( obj, 'beep', {
    'configurable': false,
    'enumerable': true,
    'writable': true,
    'value': 'boop'
});

var bool = isNonConfigurableProperty( obj, 'beep' );
// returns true

bool = isNonConfigurableProperty( obj, 'foo' );
// returns false

Notes

  • Value arguments other than null or undefined are coerced to objects.

    var bool = isNonConfigurableProperty( 'beep', 'length' );
    // returns true
    

Examples

var isNonConfigurableProperty = require( '@stdlib/assert/is-nonconfigurable-property' );

var bool = isNonConfigurableProperty( [ 'a' ], 'length' );
// returns true

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

bool = isNonConfigurableProperty( [ 'a' ], 0 );
// returns false

bool = isNonConfigurableProperty( {}, 'toString' );
// returns false

bool = isNonConfigurableProperty( {}, 'hasOwnProperty' );
// returns false

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

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

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

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