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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:53:29+00:00 2026-05-29T11:53:29+00:00

So I have the empty object a = {} . When I do console.log(a)

  • 0

So I have the empty object a = {}. When I do console.log(a), console.dir(a), or even

for(b in a) {
   console.log(b);
}

I do not get to see the “hidden properties” such as __defineGetter__, hasOwnProperty, etc.

How can I print all properties of an object?

  • 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-29T11:53:29+00:00Added an answer on May 29, 2026 at 11:53 am

    What you’re after is the non-enumerable properties of an object (and possibly those it inherits from its prototype). I don’t believe there’s any standard way to get them via JavaScript.

    If you use a debugger and inspect an object, usually all properties of an object are shown (not just the enumerable ones). All major browsers have built-in debuggers now: Chrome has Dev Tools (Ctrl+Shift+I); IE8 and up have “F12 Developer Tools”; IE7 and earlier can be debugged via the free version of VS.Net; recent versions of Firefox have tools built in, for older versions you can get the Firebug plug-in; Opera has Dragonfly.

    Update: In the comments on the question you’ve said:

    I’m using Google Chrome 17 and the only property I see using console.log is __proto__.

    Right. {} has no properties at all, just a prototype. If you click the little arrow to the left of __proto__, it will show you __proto__‘s properties. hasOwnProperty, toString, etc., are all properties {} gets from the prototype (which is Object.prototype), not properties of the object itself.

    JavaScript uses prototypical inheritance, which means an object is backed by a prototype. If you try to retrieve the value of a property the object doesn’t have, the JavaScript engine will look at the object’s prototype to see if the prototype has that property; if so, that value is used. If the prototype doesn’t have it, the engine looks at the prototype’s prototype; and so on until it reaches the root of the hierarchy. This is why you hear about objects having their own properties vs. properties they inherit.

    Here’s an example:

    Here’s a constructor function. We put a property on the prototype the JavaScript engine will assign if we use new Foo to create an object.

    function Foo() {
    }
    Foo.prototype.bar = 42;
    

    Let’s create an object using that constructor:

    var f = new Foo();
    

    f has no properties at all, and yet:

    console.log(f.bar); // 42
    

    …because since f doesn’t have a property called “bar”, the engine looks on f‘s prototype, which is the Foo.prototype object.

    Now let’s give f its own “bar” property:

    f.bar = 67;
    console.log(f.bar); // 67
    

    Now let’s remove f‘s “bar” property:

    delete f.bar;
    

    What will happen if we try to retrieve f.bar now?

    console.log(f.bar);
    

    If you said 42, you get top marks. Because f no longer has a property called “bar”, we go back to getting it from the prototype.

    Note that this relationship is live, so:

    Foo.prototype.bar = 96;
    console.log(f.bar); // 96
    

    In the 3rd edition of ECMAScript (most browsers implement something along the lines of the 3rd edition), the only way to assign a prototype to an object is via a constructor function’s prototype property, as above. With the 5th edition, a more direct way was added: Object.create, which you can pass a prototype object to directly:

    var proto = {bar: 42};
    var obj = Object.create(proto);
    console.log(obj.bar); // 42
    proto.bar = 67;
    console.log(obj.bar); // 67
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a requirement where I can get the following in an object -
I am generating an Excel file through MATLAB and I have empty cells in
I have an empty JTable, absolutely nothing in it. I need to dynamically generate
I have an empty TextView set for my ListView . When there is no
I have files which have many empty cells which appear as NaNs when I
If I have an empty tag: <tag/> How can I add text so that
Let's say I have an empty XML file like so: <root></root> And I want
Hey all, basically i have an empty AS3 fla file with just the following
I have dragged a empty asp.net table onto my webform. I generate all the
I bet somebody has solved this before, but my searches have come up empty.

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.