time-to-botec/js/node_modules/@stdlib/utils/define-nonenumerable-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

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 []