bhylu.com

Advertisements

Object Definitions

Object literals are useful for ordinary records. Shorthand properties reuse a binding name as the property name.

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 title = "Repair club";
const places = 12;
const session = {title, places};
console.log(session);

What happens

The object contains both named values.