title: Accessing a object's non enumerable properties
body: <p>Following this question: <em><a href="https://stackoverflow.com/questions/51233812/object-prototype-returns-empty-object-in-node?noredirect=1#comment89446807_51233812"><code>Object.prototype</code> returns empty object in Node</a></em> which asked</p>
  <blockquote>
  <p>Why doesn't <code>console.log(Object.prototype)</code> log the expected object and instead returns <code>{}</code>.</p>
  </blockquote>
  <p>Here was the answer:</p>
  <blockquote>
  <p>It is because the <code>console.log</code> [...] uses <code>Object.keys()</code> on objects, and it <strong>returns enumerable properties only</strong>. And <code>Object.prototype</code> contains non-enumerable properties, that is why it returns an empty node.</p>
  <p>- <a href="https://stackoverflow.com/users/6514231/amrender-singh">Amrender Singh</a></p>
  </blockquote>
  <hr />
  <p>I was wondering how I could output all properties of a given object (for instance <code>Object.prototype</code>). As shown by another answer, using <code>getOwnPropertyNames</code> works fine:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const ObjectPrototype = Object.getOwnPropertyNames(Object.prototype).reduce((object, name) =&gt; {
  
    object[name] = Object.prototype[name];
  
    return object;
  
  }, {});
  
  console.log(
    ObjectPrototype
  );</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.as-console-wrapper { max-height: 100% !important; top: 0; }</code></pre>
  </div>
  </div>
  </p>
  <p>I thought I could extract the <em>hidden</em> properties of a given object this way. But actually, it doesn't fully work.</p>
  <p>Here's an easier example: the object I'm inspecting is the object <code>{mykey: 'value'}</code>. Chrome gives me its property (<code>console.log</code> does too) but also its prototype, <code>__proto__</code> greyed out:</p>
  <p><a href="https://i.stack.imgur.com/MyTPl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MyTPl.png" alt="enter image description here" /></a></p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>let object = { mykey: 'value' };
  
  object = Object.getOwnPropertyNames(object).reduce((acc, name) =&gt; {
  
    acc[name] = object[name];
  
    return acc;
  
  }, {});
  
  console.log(
    object
  );</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.as-console-wrapper { max-height: 100% !important; top: 0; }</code></pre>
  </div>
  </div>
  </p>
  <p>The above only returns one property. I was expecting to also have <code>__proto__</code>. <strong>Is there a way to show all of one's properties including <em>hidden</em> ones? Or do I manually have to access it: i.e. reduce <code>Object.getOwnPropertyNames(object.__proto__)</code>?</strong></p>
  <hr />
  <p>PS: or in other words, how does Chrome handle <em>hidden</em> properties?</p>