bhylu.com

Advertisements

Object Display

Choose a display method that matches your purpose. Object.entries is useful for listing names and values.

Where to run this

This example uses the JavaScript console playground. Select Run to execute it; the example does not run on this lesson page.

A practical example

JavaScript

const session = {title: "Repair club", places: 12};
for (const [key, value] of Object.entries(session)) {
  console.log(key + ": " + value);
}

What happens

Each property is printed with its value.