Let’s say your writing some React code, and you end up doing something like this:
Having to write out variable names twice in your setState() statement seems a bit inefficient. Thankfully, there is a better way in ES2015:
That’s so much nicer! The object will be automatically initialized with the name of the variable as the property name. Awesome, isn’t it?