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
Did you find this page helpful?