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 7813673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:57:14+00:00 2026-06-02T04:57:14+00:00

I created this object and it’s properties: var obj = {}; Object.defineProperty( obj, value,

  • 0

I created this object and it’s properties:

var obj = {};

Object.defineProperty( obj, "value", {
  value: true,
  writable: false,
  enumerable: true,
  configurable: true
});

var name = "John";

Object.defineProperty( obj, "name", {
  get: function(){ return name; },
  set: function(value){ name = value; }
});

So then I call a for loop on them:

for ( var prop in obj ) {
  console.log( prop );
}

Which according to my tutorial, should produce the following results:

value
name

But instead it only displays value. Why is name not showing up?

  • 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-02T04:57:15+00:00Added an answer on June 2, 2026 at 4:57 am

    The default value for enumerable in defineProperty is false; non-enumerable properties do not show up in for…in loops. (That’s the whole point of the enumerable flag.) If you add enumerable:true into your second definition also, it will ‘fix’ it.

    See some docs.

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

Sidebar

Related Questions

I've created an object like this: company1.name = 'banana' company1.value = 40 I would
I've created this utility method in JS: function IsAuthenticated(userID) { var isAuthed = false;
I've created an object that contains another collection in one of it properties. This
I created this datagrid in my .aspx file. <asp:datagrid id=Computerchange runat=server AllowPaging=True PageSize=2 AutoGenerateColumns=False
I've created a few actions and object types for my application. For this question's
Can a custom event be created for any object method? To do this do
Perhaps I'm misunderstanding how this should work, but I've created an object in the
I have a script which creates a user-defined object like this: obj = new
I have created a CalendarViewerPortlet custom object JS object. In this object, I am
I have seen objects being created this way: const obj = new Foo; But

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.