No Colon Syntax

The standard key: value syntax is the normal way to create properties in an object. However, modern JavaScript provides a convenient shorthand.

If you want an object’s key to have the exact same name as an existing variable, you can omit the colon and the value entirely.

Traditional vs Shorthand

Both of these examples produce the exact same object:

const radius = 2;
const color = "red";

// Traditional Syntax
const apple1 = {
  radius: radius,
  color: color,
};

// Shorthand Syntax
const apple2 = {
  radius, // exactly the same as radius: radius
  color,  // exactly the same as color: color
};

This shorthand is heavily preferred by developers as it makes the code much less verbose and easier to read, especially when constructing large objects from existing data.