Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6054301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:08:16+00:00 2026-05-23T08:08:16+00:00

If I define an object and set its configurable property to false, but leave

  • 0

If I define an object and set its configurable property to false, but leave all other props alone, and later attempt to set that object’s writable prop to false, then back to true, a TypeError is thrown.

Here’s a breakdown of how I’m doing this, although I have attempted this by altering only one object data descriptor in dot notation, and also by altering all data descriptors of the object in object literal, and neither form has worked.

// simple object, and the data descriptor
var o = {name : "tom"},
    dataDesc = Object.getOwnPropertyDescriptor(o, "name");

noConfig();
alert(dataDesc.writable);  // alerts true

readOnly();
alert (dataDesc.writable); // alerts false

writable();
alert (dataDesc.writable); // error is thrown within writable() - alerts true

// early in the script, altering only configurable property
function noConfig(){
  dataDesc.configurable = false;
}

// later in the script, altering only writable property
function readOnly(){

  dataDesc.writable = false; // configurable = false; writable = false;
  Object.defineProperty(o, "name", dataDesc); // works finely
}

function writable(){
    try{
      dataDesc.writable = true; // configurable = false; writable = true;
      Object.defineProperty(o, "name", dataDesc); // throws TypeError
    }catch(e){
      alert(e); // alerts: "TypeError: Cannot redefine property: defineProperty"
    }
}

I could find nothing to help in the spec, but the MDC article for defineProperty states that, even after an object property is rendered unconfigurable, the writable data descriptor can still be modified. All others cannot, but writable can.

So, is this something in Chrome, or am I doing this wrong?

/* UPDATE */

This has been resolved – just read the spec 8.12.9 section 10.a.i

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T08:08:16+00:00Added an answer on May 23, 2026 at 8:08 am

    The error isn’t coming from dataDesc.writable = true;, it’s coming from Object.defineProperty(o, "name", dataDesc);…which is correct, since {name : "tom"} does already have a name property defined.

    This is the correct behavior, you are able to change writable and not able to redefine the name property.

    I think the confusion comes from the behavior, you don’t need to call .defineProperty() for .writable to take effect, you can test it here.

    Note: I commented out .configurable = false in the above example, which would lock the property attributes and not allow you to change writable further, leaving it stuck in false in your original code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So, I want to define a singleton method for an object, but I want
Given an object obj , I would like to define a read-only property 'prop'
How should I define a Moose object subroutine after its initialization? I'm writing an
I am wondering how I can define an object in C whose reference will
public object MethodName(ref float y) { // elided } How do I define a
Im trying to define a dataTemplate for a business object in my wpf application
Given that users must be able to define their own fields on an object,
In PHP, if you define a class, and then instantiate an object of that
I have build a UITabBarController programmatically and populated its viewControllers property. When I run
edit2: solution SQLite and `Object reference not set` exception I am having a hard

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.