Vue · Middle · Question 40 of 75

What does store.$patch offer?

cart.$patch((state) => {
  state.items.push(item);
  state.updatedAt = Date.now();
});

Explanation

$patch takes a partial object or a function. Direct assignments (cart.total = 0) also work; $patch is useful for batching and readability.

Further reading

Problem with a question

Vue · Middle · question 40

Test yourself

Take the Vue · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz