Sandwell
Sandwell

Reputation: 1457

Chrome developer tools console showing faded Javascript object property, why?

I've logged a Javascript Object to find a property. But it appears some of them are faded.

enter image description here

Is that private propeties ?

Upvotes: 0

Views: 496

Answers (1)

Máté Safranka
Máté Safranka

Reputation: 4116

Not private, just non-enumerable. It means if you iterate over your object with a for..in loop, the loop will skip them. You can still access them directly by name.

Properties you add to the object are enumerable by default. You can make them non-enumerable by calling e.g. Object.defineProperty(obj, 'ytd_sale', { enumerable: false });

More info: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty

Upvotes: 1

Related Questions