Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do the colors mean in Chrome Developer Tools Scope panel?

I am curious why some variables are solid and some variables are half opacity. What is the difference between them? Both variations are available in the global scope.

screenshot

like image 800
Eric Majerus Avatar asked Apr 10 '16 20:04

Eric Majerus


People also ask

What is purple color in Chrome DevTools?

It shows the available space where text can be expanded. You can see this dashed area after text which means it is area where text can be expanded.

What is green in inspect element?

The blue color is the element's "content size", i.e. the area which holds text and/or other elements within it. The green color is the element's padding, and the orange color is the element's margin.

How do you find the color code on Inspect Element?

You can easily find the HEX or RGB color code used on a particular web page, using the native option in Google Chrome. Right-click on the color, and click on Inspect. Most of the time, you will get the color code on the right-hand side with other CSS.

What is padding green?

Paddington Green is a green space and conservation area in the City of Westminster located off Edgware Road and adjacent to the Westway. It is the oldest part of Paddington and became a separate conservation area in 1988, having previously formed part of Maida Vale conservation area.


1 Answers

If the property is shown dimmed that means it's not enumerable. So it won't show up in when you loop through the object's properties:

Take the location object as an example:

Location logged in console

When enumerating the properties toString, valueOf and __proto__ don't show up:

var keys = []; for (var key in location) { keys.push(key) }; console.log(keys)
-> ["replace", "assign", "hash", "search", "pathname", "port", "hostname", "host",  
"protocol", "origin", "href", "ancestorOrigins", "reload"]

You can use propertyIsEnumerable to find out if the property will show up when you loop over the object:

location.propertyIsEnumerable("search")
// true
location.propertyIsEnumerable("toString")
// false

By default all properties of an object are enumerable:

post.title is enumerable

But you can change that by using defineProperty:

Object.defineProperty(post, "author", {
     value: "John Doe",
     enumerable: false
});

When you log that object to the console the author property appears in a slightly lighter shade of purple.

(It seems the shorthand version doesn't have support for this formatting feature, but we can force DevTools to use the longer version for a small object using the dir function.)

author property isn't enumerable

like image 53
Matt Zeunert Avatar answered Oct 26 '22 09:10

Matt Zeunert