Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the significance of faded properties when using console.dir in Chrome Developer Tools Console

What does it mean when an object's property is slightly faded when using console.dir() in chrome's console.

For example, take a look at "top,width,worldVisible,x & y" in this screenshot.

Screenshot of developer tools

I've looked at the API reference here https://developer.chrome.com/devtools/docs/console-api#consoledirobject, but had no luck.

Thanks

like image 255
Ben Avatar asked Apr 23 '15 11:04

Ben


People also ask

What is the purpose of the console tab in Chrome DevTools?

Another key function of the console is that it allows the developer to inspect the code and interact with it while executing. In the DevTools Sources tab you can find all the source files of your application and apply breakpoints³ to pause the execution.

What does console Dir do?

The method console. dir() displays an interactive list of the properties of the specified JavaScript object. The output is presented as a hierarchical listing with disclosure triangles that let you see the contents of child objects. In other words, console.

How do I view console errors in Chrome?

In Chrome, navigate to Tools > Advanced > Error Console. The error console will open. Select JavaScript and Errors from the two drop downs. To find the error location, expand one of the errors.


1 Answers

Faded properties apper to indicate non-enumerable properties. If we do:

var a = {}; Object.defineProperties(a, {     hello: { enumerable: false },     world: { enumerable: true } }); console.dir(a); 

then we see that hello is faded, while world is not.

console image showing faded <code>hello</code> property

In your code, if you do for(prop in obj) { console.log(prop); } (where obj is whatever object you're showing us in your console screenshot), you'll see that only the faded properties are not enumerated.

You can also check this with Object.getOwnPropertyDescriptor(obj, "worldVisible"), which should return an object with an enumerable: false property.

Note that the italics on the property names indicate that the property value is defined by a getter function. (This also causes the value to display a (...) value before the function is run.) This is a totally separate issue from enumerability, which causes the names to be faded. You can have italic getter-defined properties that are not faded non-enumerable properties, and vice versa.

like image 74
apsillers Avatar answered Oct 11 '22 11:10

apsillers