# Redefine an existing property to an object

**URL:** <https://es.discourse.group/t/redefine-an-existing-property-to-an-object/704>\
**Category:** I have questions\
**Tags:** proposal\
**Created:** [March 19, 2021, 5:22am UTC](https://es.discourse.group/t/redefine-an-existing-property-to-an-object/704 "2021-03-19T05:22:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![feely](https://avatars.discourse-cdn.com/v4/letter/f/278dde/32.png) [@feely](https://es.discourse.group/u/feely)\
**Post date:** [March 19, 2021, 5:22am UTC](https://es.discourse.group/t/redefine-an-existing-property-to-an-object/704/1 "2021-03-19T05:22:16Z")

</div>

```javascript
const o = { key: '1' };
Object.defineProperty(o, 'key', { value: '2' });
// configurable of `o.key` is true

Object.defineProperty(o, 'newKey', { value: '2' });
// configurable of `o.newKey` is false

```

I have read the spec of `DefineProperty`, the result of above code is correct, but It's still confusing for me.  
Why not make the configurable of property `key` to be the default value `false`? As the document at MDN:  
[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global\_Objects/Object/defineProperty#description](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty#description)

---

<div class="post-metadata">

**Author:** ![aclaymore](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/aclaymore/32/501_2.png) [@aclaymore](https://es.discourse.group/u/aclaymore)\
**Post date:** [March 19, 2021, 7:37am UTC](https://es.discourse.group/t/redefine-an-existing-property-to-an-object/704/2 "2021-03-19T07:37:15Z")

</div>

The ‘key’ property was already defined, so ‘defineProperty’ is modifying the existing definition. The default values are only applied when creating a new property.

This did suprise me the first time I found this out and potentially ‘defineProperty’ was not the best name for that api.

It might be worth suggesting an update on the MDN page to ensure this behaviour is clearer.

---

<div class="post-metadata">

**Author:** ![feely](https://avatars.discourse-cdn.com/v4/letter/f/278dde/32.png) [@feely](https://es.discourse.group/u/feely)\
**Post date:** [March 19, 2021, 5:16pm UTC](https://es.discourse.group/t/redefine-an-existing-property-to-an-object/704/3 "2021-03-19T17:16:22Z")

</div>

Is it possible to revise the `DefineProperty` to make the definition clearer?

---

<div class="post-metadata">

**Author:** ![senocular](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/senocular/32/642_2.png) [@senocular](https://es.discourse.group/u/senocular)\
**Post date:** [April 19, 2021, 1:15pm UTC](https://es.discourse.group/t/redefine-an-existing-property-to-an-object/704/5 "2021-04-19T13:15:35Z")

</div>

If you're talking about MDN, then you can make edit suggestions through github: [Edit](https://github.com/mdn/content/blob/97ba5ae29ec7287b4d05a0251cb389f5c594ec1f/files/en-us/web/javascript/reference/global_objects/object/defineproperty/index.html), [Report](https://github.com/mdn/content/issues/new?body=MDN+URL%3A+https%3A%2F%2Fdeveloper.mozilla.org%2Fen-US%2Fdocs%2FWeb%2FJavaScript%2FReference%2FGlobal_Objects%2FObject%2FdefineProperty%0A%0A%23%23%23%23+What+information+was+incorrect%2C+unhelpful%2C+or+incomplete%3F%0A%0A%0A%23%23%23%23+Specific+section+or+headline%3F%0A%0A%0A%23%23%23%23+What+did+you+expect+to+see%3F%0A%0A%0A%23%23%23%23+Did+you+test+this%3F+If+so%2C+how%3F%0A%0A%0A%3C%21--+Do+not+make+changes+below+this+line+--%3E%0A%3Cdetails%3E%0A%3Csummary%3EMDN+Content+page+report+details%3C%2Fsummary%3E%0A%0A*+Folder%3A+%60en-us%2Fweb%2Fjavascript%2Freference%2Fglobal_objects%2Fobject%2Fdefineproperty%60%0A*+MDN+URL%3A+https%3A%2F%2Fdeveloper.mozilla.org%2Fen-US%2Fdocs%2FWeb%2FJavaScript%2FReference%2FGlobal_Objects%2FObject%2FdefineProperty%0A*+GitHub+URL%3A+https%3A%2F%2Fgithub.com%2Fmdn%2Fcontent%2Fblob%2Fmain%2Ffiles%2Fen-us%2Fweb%2Fjavascript%2Freference%2Fglobal_objects%2Fobject%2Fdefineproperty%2Findex.html%0A*+Last+commit%3A+https%3A%2F%2Fgithub.com%2Fmdn%2Fcontent%2Fcommit%2Fb99415974d2280f313887bd670faf1341ad5b6a8%0A*+Document+last+modified%3A+2021-04-15T03%3A41%3A48.000Z%0A%0A%3C%2Fdetails%3E&title=Issue+with+%22Object.defineProperty%28%29%22%3A+%28short+summary+here+please%29&labels=Content%3AJavaScript%2Cneeds-triage).
