score:3

Accepted answer

it's the spread properties syntax and it's creating a shallow copy of this.state.cars. that means that this line:

cars[`car-${timestamp}`] = car;

doesn't result in an additional key being added to this.state.cars. that is, it's being used specifically so that this.state.cars is not mutated.

for spread properties to be included in your babel configuration, you'd need to be using the babel-plugin-syntax-object-rest-spread and babel-plugin-transform-object-rest-spread plugins - which are included in the stage-2 preset.


Related Query

More Query from same tag