Object keys w/o values

I was reading documentation on reducers, when a piece of code popped up that didn’t make any sense to me. The documentation was going over combining reducers and had this bit of code:

const todoApp = combineReducers({
  visibilityFilter,
  todos
})

I noticed they passed in an object to the combineReducers method but both of the keys/properties in the object didn’t have values to them.
Above the code in the documentation are two reducer functions with the same name as both keys.

Since es6, is it possible to use a shorter syntax to declare object properties.

const a  = 'foo';
const b = 'bar';
const c = 1 + 1;

const traditional = {
  a: a,
  b: b,
  c: c,
}

// since es6 you can use a shorter syntax
const short = {
  a,
  b,
  c,
}

// they both produce
{ a: 'foo', b: 'bar', c: 2 }
3 Likes