Found this in a tutorial I was going over. It's ES6.
I'm just not sure whats exactly going on. Namely , the way the function(?) is being declared with the array. Where is the colon that declares it as a function?
[types.ADD_TO_CART] (state, { id })
Also what's up with the brackets in the parameter declaration?
(state, { id })
Here's the tutorial.
https://medium.com/@connorleech/build-a-shopping-cart-with-vue-2-and-vuex-5d58b93c513f
[types.ADD_TO_CART] (state, { id }) {
const record = state.added.find(p => p.id === id)
if (!record) {
state.added.push({
id,
quantity: 1
})
} else {
record.quantity++
}
}