Consider a reactive object created with reactive(). What will happen if you add a new property directly after creation?
import { reactive } from 'vue'; const state = reactive({ count: 0 }); state.newProp = 123; console.log(state.newProp);
Think about how Vue tracks reactivity on object properties.
Vue's reactive() wraps existing properties to be reactive. Adding new properties directly after creation does not make them reactive automatically. To add reactive properties later, you should use ref() or reactive() properly.
Given the following code, what will be logged to the console?
import { reactive } from 'vue'; const state = reactive({ items: [1, 2, 3] }); state.items.push(4); console.log(state.items.length);
Arrays inside reactive objects are reactive. What happens when you push an item?
Vue wraps arrays inside reactive objects, so mutating methods like push are reactive and update the array length. The console logs 4 because the new item was added.
toRefs to avoid losing reactivity when destructuring?Given a reactive object, which code snippet correctly destructures properties while preserving reactivity?
import { reactive, toRefs } from 'vue'; const state = reactive({ count: 0, name: 'Vue' }); // Destructure here
Think about how to keep reactivity when extracting properties.
Direct destructuring (option D) breaks reactivity because it copies values. Using toRefs returns refs for each property, preserving reactivity. Option D is correct.
Examine the code below. Why does changing state.user.address.city not update the template?
import { reactive } from 'vue'; const state = reactive({ user: {} }); state.user.address = { city: 'Paris' }; // Later in code state.user.address.city = 'London';
Think about when properties are added to reactive objects.
Vue's reactive() only makes existing properties reactive. Adding address after creation means it is not reactive. Changes to city inside address won't trigger updates.
Which statement best describes Vue's behavior when deleting a property from a reactive object?
Consider how Vue tracks changes to object properties.
Vue's reactivity system does not detect property deletions. Deleting a property does not trigger updates, so the UI may not reflect the change unless handled explicitly.