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