1.9 KiB
1.9 KiB
Non-Enumerable Property
Define a non-enumerable property.
Usage
var setNonEnumerableProperty = require( '@stdlib/utils/define-nonenumerable-property' );
setNonEnumerableProperty( obj, prop, value )
Defines a non-enumerable property.
var obj = {};
setNonEnumerableProperty( obj, 'foo', 'bar' );
var v = obj.foo;
// returns 'bar'
Notes
- Non-enumerable properties are writable and configurable.
Examples
var objectKeys = require( '@stdlib/utils/keys' );
var setNonEnumerableProperty = require( '@stdlib/utils/define-nonenumerable-property' );
function Foo( name ) {
if ( !(this instanceof Foo) ) {
return new Foo( name );
}
setNonEnumerableProperty( this, 'name', name );
return this;
}
var foo = new Foo( 'beep' );
var v = foo.name;
// returns 'beep'
var keys = objectKeys( foo );
// returns []