README.md (2629B)
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 # nonEnumerablePropertyNames 22 23 > Return an array of an object's own non-enumerable property names. 24 25 <section class="usage"> 26 27 ## Usage 28 29 <!-- eslint-disable id-length --> 30 31 ```javascript 32 var nonEnumerablePropertyNames = require( '@stdlib/utils/nonenumerable-property-names' ); 33 ``` 34 35 #### nonEnumerablePropertyNames( obj ) 36 37 Returns an `array` of an object's own non-enumerable property names. 38 39 ```javascript 40 var defineProperty = require( '@stdlib/utils/define-property' ); 41 42 var obj = { 43 'a': 'b' 44 }; 45 46 defineProperty( obj, 'c', { 47 'configurable': false, 48 'enumerable': false, 49 'writable': true, 50 'value': 'd' 51 }); 52 53 var keys = nonEnumerablePropertyNames( obj ); 54 // returns [ 'c' ] 55 ``` 56 57 </section> 58 59 <!-- /.usage --> 60 61 <section class="notes"> 62 63 ## Notes 64 65 - Name order is not guaranteed, as `object` key enumeration is not specified according to the [ECMAScript specification][ecma-262-for-in]. In practice, however, most engines use insertion order to sort an `object`'s keys, thus allowing for deterministic extraction. 66 67 </section> 68 69 <!-- /.notes --> 70 71 <section class="examples"> 72 73 ## Examples 74 75 <!-- eslint-disable id-length --> 76 77 <!-- eslint no-undef: "error" --> 78 79 ```javascript 80 var defineProperty = require( '@stdlib/utils/define-property' ); 81 var nonEnumerablePropertyNames = require( '@stdlib/utils/nonenumerable-property-names' ); 82 83 function Foo() { 84 this.beep = 'boop'; 85 this.a = { 86 'b': 'c' 87 }; 88 defineProperty( this, 'baz', { 89 'configurable': true, 90 'enumerable': false, 91 'writable': true, 92 'value': 'qux' 93 }); 94 return this; 95 } 96 97 Foo.prototype.foo = [ 'bar' ]; 98 defineProperty( Foo.prototype, 'bip', { 99 'configurable': false, 100 'enumerable': false, 101 'writable': false, 102 'value': 'bop' 103 }); 104 105 var obj = new Foo(); 106 var keys = nonEnumerablePropertyNames( obj ); 107 108 console.log( keys ); 109 // => [ 'baz' ] 110 ``` 111 112 </section> 113 114 <!-- /.examples --> 115 116 <section class="links"> 117 118 [ecma-262-for-in]: http://www.ecma-international.org/ecma-262/5.1/#sec-12.6.4 119 120 </section> 121 122 <!-- /.links -->