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