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