README.md (2137B)
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 # inheritedPropertySymbols 22 23 > Return an array of an object's inherited [symbol][@stdlib/symbol/ctor] properties. 24 25 <section class="usage"> 26 27 ## Usage 28 29 ```javascript 30 var inheritedPropertySymbols = require( '@stdlib/utils/inherited-property-symbols' ); 31 ``` 32 33 #### inheritedPropertySymbols( obj\[, level] ) 34 35 Returns an `array` of an object's inherited [symbol][@stdlib/symbol/ctor] properties. 36 37 ```javascript 38 var symbols = inheritedPropertySymbols( [ 1, 2, 3 ] ); 39 ``` 40 41 By default, the function walks an object's entire prototype chain. To limit the inheritance level, provide a `level` argument. 42 43 ```javascript 44 var symbols = inheritedPropertySymbols( [ 1, 2, 3 ], 1 ); 45 ``` 46 47 </section> 48 49 <!-- /.usage --> 50 51 <section class="notes"> 52 53 </section> 54 55 <!-- /.notes --> 56 57 <section class="examples"> 58 59 ## Examples 60 61 <!-- eslint no-undef: "error" --> 62 63 ```javascript 64 var hasSymbolSupport = require( '@stdlib/assert/has-symbol-support' ); 65 var Symbol = require( '@stdlib/symbol/ctor' ); 66 var inheritedPropertySymbols = require( '@stdlib/utils/inherited-property-symbols' ); 67 68 var hasSymbols; 69 var symbols; 70 var obj; 71 72 hasSymbols = hasSymbolSupport(); 73 74 function Foo() { 75 if ( hasSymbols ) { 76 this[ Symbol( 'a' ) ] = 'b'; 77 } 78 return this; 79 } 80 81 if ( hasSymbols ) { 82 Foo.prototype[ Symbol( 'c' ) ] = 'd'; 83 } 84 85 obj = new Foo(); 86 symbols = inheritedPropertySymbols( obj ); 87 88 console.log( symbols ); 89 ``` 90 91 </section> 92 93 <!-- /.examples --> 94 95 <section class="links"> 96 97 [@stdlib/symbol/ctor]: https://www.npmjs.com/package/@stdlib/symbol-ctor 98 99 </section> 100 101 <!-- /.links -->