How to count the number of attributes in a JavaScript object

Learn how to count how many properties a JavaScript object has

useObject.keys()Method, passing the object to be checked to obtain an array of all (own) enumerable properties of the object.

Then pass inspectionlengthproperty:

const car = {
  color: 'Blue',
  brand: 'Ford',
  model: 'Fiesta'


I said countless attributes. This means that their internal enumerable flag is set to true, which is the default setting.Check MDNMore information on this topic.

Download mine for freeJavaScript beginner's manual

More js tutorials: