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