0

I run into this piece of code while learning Redux. I am sure that the funtion returning an object and the object has type, id, text properties. I know that type equal to ADD_TODO and id equal to nextTodoId++. But I have no idea about the last property. Does it mean that text: text ?

export const addTodo = text => ({
  type: 'ADD_TODO',
  id: nextTodoId++,
  text
})
G'ofur N
  • 2,582
  • 3
  • 14
  • 21
  • _"Does it mean that `text: text`"_ <- yes! – Phil Aug 06 '18 at 05:57
  • It's a new ES6 feature, if your key and value are same you don't have to repeat it, You can read more about it here http://www.benmvp.com/learning-es6-enhanced-object-literals/ – Anjum.... Aug 06 '18 at 06:01

0 Answers0