README.md (1955B)
1 <!-- 2 3 @license Apache-2.0 4 5 Copyright (c) 2018 The Stdlib Authors. 6 7 Licensed under the Apache License, Version 2.0 (the "License"); 8 you may not use this file except in compliance with the License. 9 You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13 Unless required by applicable law or agreed to in writing, software 14 distributed under the License is distributed on an "AS IS" BASIS, 15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 See the License for the specific language governing permissions and 17 limitations under the License. 18 19 --> 20 21 # Non-Enumerable Property 22 23 > [Define][@stdlib/utils/define-property] a **non-enumerable** property. 24 25 <section class="usage"> 26 27 ## Usage 28 29 ```javascript 30 var setNonEnumerableProperty = require( '@stdlib/utils/define-nonenumerable-property' ); 31 ``` 32 33 #### setNonEnumerableProperty( obj, prop, value ) 34 35 [Defines][@stdlib/utils/define-property] a **non-enumerable** property. 36 37 ```javascript 38 var obj = {}; 39 40 setNonEnumerableProperty( obj, 'foo', 'bar' ); 41 42 var v = obj.foo; 43 // returns 'bar' 44 ``` 45 46 </section> 47 48 <!-- /.usage --> 49 50 <section class="notes"> 51 52 ## Notes 53 54 - Non-enumerable properties are **writable** and **configurable**. 55 56 </section> 57 58 <!-- /.notes --> 59 60 <section class="examples"> 61 62 ## Examples 63 64 <!-- eslint no-undef: "error" --> 65 66 ```javascript 67 var objectKeys = require( '@stdlib/utils/keys' ); 68 var setNonEnumerableProperty = require( '@stdlib/utils/define-nonenumerable-property' ); 69 70 function Foo( name ) { 71 if ( !(this instanceof Foo) ) { 72 return new Foo( name ); 73 } 74 setNonEnumerableProperty( this, 'name', name ); 75 return this; 76 } 77 78 var foo = new Foo( 'beep' ); 79 80 var v = foo.name; 81 // returns 'beep' 82 83 var keys = objectKeys( foo ); 84 // returns [] 85 ``` 86 87 </section> 88 89 <!-- /.examples --> 90 91 <section class="links"> 92 93 [@stdlib/utils/define-property]: https://www.npmjs.com/package/@stdlib/utils/tree/main/define-property 94 95 </section> 96 97 <!-- /.links -->