@stdlib/assert-is-nonenumerable-property
v0.1.2
Published
Test if an object's own property is non-enumerable.
Downloads
178
Readme
isNonEnumerableProperty
Test if an object's own property is non-enumerable.
Installation
npm install @stdlib/assert-is-nonenumerable-property
Usage
var isNonEnumerableProperty = require( '@stdlib/assert-is-nonenumerable-property' );
isNonEnumerableProperty( value, property )
Returns a boolean
indicating if a value
has a non-enumerable property
.
var defineProperty = require( '@stdlib/utils-define-property' );
var obj = {
'foo': 'bar'
};
defineProperty( obj, 'beep', {
'configurable': false,
'enumerable': false,
'writable': true,
'value': 'boop'
});
var bool = isNonEnumerableProperty( obj, 'beep' );
// returns true
bool = isNonEnumerableProperty( obj, 'foo' );
// returns false
Notes
Value arguments other than
null
orundefined
are coerced toobjects
.var bool = isNonEnumerableProperty( 'beep', 'length' ); // returns true
Examples
var isNonEnumerableProperty = require( '@stdlib/assert-is-nonenumerable-property' );
var bool = isNonEnumerableProperty( [ 'a' ], 'length' );
// returns true
bool = isNonEnumerableProperty( { 'a': 'b' }, 'a' );
// returns false
bool = isNonEnumerableProperty( [ 'a' ], 0 );
// returns false
bool = isNonEnumerableProperty( {}, 'toString' );
// returns false
bool = isNonEnumerableProperty( {}, 'hasOwnProperty' );
// returns false
bool = isNonEnumerableProperty( null, 'a' );
// returns false
bool = isNonEnumerableProperty( void 0, 'a' );
// returns false
bool = isNonEnumerableProperty( { 'null': false }, null );
// returns false
bool = isNonEnumerableProperty( { '[object Object]': false }, {} );
// returns false
See Also
@stdlib/assert-is-configurable-property
: test if an object's own property is configurable.@stdlib/assert-is-enumerable-property
: test if an object's own property is enumerable.@stdlib/assert-is-nonconfigurable-property
: test if an object's own property is non-configurable.@stdlib/assert-is-nonenumerable-property-in
: test if an object's own or inherited property is non-enumerable.@stdlib/assert-is-readable-property
: test if an object's own property is readable.@stdlib/assert-is-writable-property
: test if an object's own property is writable.
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
License
See LICENSE.
Copyright
Copyright © 2016-2024. The Stdlib Authors.