2.9 KiB
2.9 KiB
nonEnumerablePropertiesIn
Return an array of an object's own and inherited non-enumerable property names and symbols.
Usage
var nonEnumerablePropertiesIn = require( '@stdlib/utils/nonenumerable-properties-in' );
nonEnumerablePropertiesIn( obj )
Returns an array
of an object's own and inherited non-enumerable property names and symbols.
var defineProperty = require( '@stdlib/utils/define-property' );
var obj = {};
defineProperty( obj, 'a', {
'configurable': false,
'enumerable': false,
'writable': false,
'value': 'a'
});
var props = nonEnumerablePropertiesIn( obj );
// returns [ 'a', ... ]
Examples
var defineProperty = require( '@stdlib/utils/define-property' );
var hasSymbolSupport = require( '@stdlib/assert/has-symbol-support' );
var Symbol = require( '@stdlib/symbol/ctor' );
var nonEnumerablePropertiesIn = require( '@stdlib/utils/nonenumerable-properties-in' );
var hasSymbols;
var props;
var obj;
hasSymbols = hasSymbolSupport();
function Foo() {
this.a = 'a';
defineProperty( this, 'b', {
'configurable': false,
'enumerable': false,
'writable': true,
'value': 'b'
});
if ( hasSymbols ) {
this[ Symbol( 'a' ) ] = 'a';
defineProperty( this, Symbol( 'b' ), {
'configurable': false,
'enumerable': false,
'writable': true,
'value': 'b'
});
}
return this;
}
Foo.prototype.foo = 'bar';
defineProperty( Foo.prototype, 'beep', {
'configurable': false,
'enumerable': false,
'writable': false,
'value': 'boop'
});
if ( hasSymbols ) {
Foo.prototype[ Symbol( 'foo' ) ] = 'bar';
defineProperty( Foo.prototype, Symbol( 'beep' ), {
'configurable': false,
'enumerable': false,
'writable': false,
'value': 'boop'
});
}
obj = new Foo();
props = nonEnumerablePropertiesIn( obj );
console.log( props );
// e.g., => [ 'b', 'beep', ... ]