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

  • SEARCH
  • Home
  • 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 8290443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:48:58+00:00 2026-06-08T12:48:58+00:00

Being a beginner in javascript, i tried to understand Object.create() method from here https://developer-new.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/create

  • 0

Being a beginner in javascript, i tried to understand Object.create() method from here

https://developer-new.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/create

In the example code, line 18. A accessor property is created with writable set to true. I also read that writable is only for data descriptors.

Tried running,

var o = Object.create(Object.prototype, {
  // foo is a regular "value property"
  foo: { 
    writable:true, configurable:true, value: "hello" 
  },
  // bar is a getter-and-setter (accessor) property
  bar: {
    writable: true,
    configurable: false,
    get: function() { return 10 },
    set: function(value) { console.log("Setting `o.bar` to", value) }
  }
  });
console.log(o); 

I get invalid property error.

  • 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-06-08T12:48:59+00:00Added an answer on June 8, 2026 at 12:48 pm

    The issue is that writable and set/get are mutually exclusive. The code generates this helpful error in Chrome:

    Invalid property. A property cannot both have accessors and be writable...
    

    This makes some logical sense: if you have set/get accessors on a property, that property is never going to be written to and/or read from, because any attempts to read/write it will be intercepted by the accessor functions. If you define a property as writable and give it accessor functions, you are simultaneously saying:

    1. “The value of this property can be directly altered,” and
    2. “Block all attempts to read and/or write to this property; instead, use these functions.”

    The error is simply stopping you from specifying a contradiction. I assume from the fact that you wrote a getter and setter, you don’t really want the property to be writable. Just remove that line, and your code runs perfectly.

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

Sidebar

Related Questions

Background: I am a beginner javascript developer who is trying to understand and learn
Sorry in advance for this being such a beginner question. Here are the steps
Being new to c#, I don't understand how variables are passed between objects. My
First of all, forgive me for being a beginner to Javascript and PHP. Second:
Being a beginner I am having difficulty to understand the following statement a)If in
Being a beginner I am finding it very hard to understand delegates, so I'll
I have came across the following code, and being a C beginner, I came
Being new to SQLAlchemy, I was wondering at what time would Session() should be
Being new to OpenCL i would like to know if the following scenario is
Being quite new to rails and currently building a project, i'm begining to be

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.