Complete the code to create a readonly reactive object in Vue.
import { reactive, [1] } from 'vue'; const state = reactive({ count: 0 }); const readonlyState = [1](state);
ref instead of readonly.computed for immutability.The readonly function creates an immutable reactive object in Vue.
Complete the code to prevent modification of a reactive object using readonly.
import { reactive, readonly } from 'vue'; const data = reactive({ name: 'Vue' }); const immutableData = readonly([1]);
name or immutableData.reactive function instead of an object.You pass the reactive object data to readonly to make it immutable.
Fix the error in the code to correctly create a readonly reactive object.
import { reactive, [1] } from 'vue'; const state = reactive({ value: 10 }); const frozenState = [1](state);
ref or reactive instead of readonly.readonly from 'vue'.The function to create an immutable reactive object is readonly.
Fill both blanks to create a readonly reactive object and try to modify it safely.
import { reactive, [1] } from 'vue'; const original = reactive({ count: 5 }); const safeCopy = [1](original); safeCopy.count = 10; // This will [2]
ref instead of readonly.Using readonly creates an immutable object. Trying to modify it will throw an error in development.
Fill all three blanks to create a readonly reactive object, access its property, and explain immutability.
import { reactive, [1] } from 'vue'; const state = reactive({ message: 'Hello' }); const frozenState = [1](state); console.log(frozenState.[2]); // Outputs 'Hello' // Trying to change frozenState.[2] will [3]
readonly makes the reactive object immutable. Accessing properties works normally, but changing them throws an error.