README.md (3172B)
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 # isConfigurablePropertyIn 22 23 > Test if an object's own or inherited property is configurable. 24 25 <section class="usage"> 26 27 ## Usage 28 29 ```javascript 30 var isConfigurablePropertyIn = require( '@stdlib/assert/is-configurable-property-in' ); 31 ``` 32 33 #### isConfigurablePropertyIn( value, property ) 34 35 Returns a `boolean` indicating if a `value` has a configurable `property` (i.e., a property which may be deleted or whose descriptor may be changed). 36 37 <!-- eslint-disable no-restricted-syntax --> 38 39 ```javascript 40 var defineProperty = require( '@stdlib/utils/define-property' ); 41 42 var bool; 43 var obj; 44 45 function Foo() { 46 this.foo = 'bar'; 47 return this; 48 } 49 50 defineProperty( Foo.prototype, 'beep', { 51 'configurable': true, 52 'enumerable': true, 53 'writable': true, 54 'value': true 55 }); 56 57 defineProperty( Foo.prototype, 'boop', { 58 'configurable': false, 59 'enumerable': true, 60 'writable': true, 61 'value': true 62 }); 63 64 obj = new Foo(); 65 66 bool = isConfigurablePropertyIn( obj, 'foo' ); 67 // returns true 68 69 bool = isConfigurablePropertyIn( obj, 'beep' ); 70 // returns true 71 72 bool = isConfigurablePropertyIn( obj, 'boop' ); 73 // returns false 74 ``` 75 76 </section> 77 78 <!-- /.usage --> 79 80 <section class="notes"> 81 82 ## Notes 83 84 - Value arguments other than `null` or `undefined` are coerced to `objects`. 85 86 ```javascript 87 var bool = isConfigurablePropertyIn( 'beep', 'toString' ); 88 // returns true 89 ``` 90 91 - Property arguments are coerced to `strings`. 92 93 ```javascript 94 var obj = { 95 'null': 'foo' 96 }; 97 98 var bool = isConfigurablePropertyIn( obj, null ); 99 // returns true 100 ``` 101 102 </section> 103 104 <!-- /.notes --> 105 106 <section class="examples"> 107 108 ## Examples 109 110 <!-- eslint-disable object-curly-newline --> 111 112 <!-- eslint no-undef: "error" --> 113 114 ```javascript 115 var isConfigurablePropertyIn = require( '@stdlib/assert/is-configurable-property-in' ); 116 117 var bool = isConfigurablePropertyIn( { 'a': 'b' }, 'a' ); 118 // returns true 119 120 bool = isConfigurablePropertyIn( [ 'a' ], 0 ); 121 // returns true 122 123 bool = isConfigurablePropertyIn( { 'null': false }, null ); 124 // returns true 125 126 bool = isConfigurablePropertyIn( { '[object Object]': false }, {} ); 127 // returns true 128 129 bool = isConfigurablePropertyIn( {}, 'toString' ); 130 // returns true 131 132 bool = isConfigurablePropertyIn( {}, 'hasOwnProperty' ); 133 // returns true 134 135 bool = isConfigurablePropertyIn( [ 'a' ], 'length' ); 136 // returns false 137 138 bool = isConfigurablePropertyIn( null, 'a' ); 139 // returns false 140 141 bool = isConfigurablePropertyIn( void 0, 'a' ); 142 // returns false 143 ``` 144 145 </section> 146 147 <!-- /.examples --> 148 149 <section class="links"> 150 151 </section> 152 153 <!-- /.links -->