Sample questions
Question 1Easy
What does a ref return when you create it with ref(0)?
- An object with a
.value property holding 0 - The number 0 itself, copied into a plain variable that Vue watches
- A plain array [0]
- A function that returns 0
Answer: A. An object with a .value property holding 0
Explanation
ref() wraps the value in a reactive object whose .value you read and write in script code.
Step-by-step solution
- Call
ref(0). - Vue wraps 0 in an object.
- Access it with
.value in script.
Why the other options are wrong
- B. A ref wraps the value in an object.
- C. An array is not used.
- D. It is an object, not a function.
Tip: Templates unwrap refs automatically; scripts do not.
Question 2Easy
Which function makes an object deeply reactive in Vue 3?
- reactive()
- ref.object()
- observe()
- Vue.set()
Answer: A. reactive()
Explanation
reactive(obj) returns a Proxy that tracks nested property access.
Step-by-step solution
- Pass a plain object.
- Get back a Proxy.
- Reads and writes are tracked.
Why the other options are wrong
- B. No such function exists.
- C. observe is a Vue 2 internals term, not an API.
- D. Vue.set was for Vue 2 and is not needed.
Question 3Easy
Why is {{ count }} in the template not written as {{ count.value }}?
- It is a typo, since templates need .value just like script code does
- Vue runs eval
- Top-level refs are automatically unwrapped in templates
- Refs are numbers
Answer: C. Top-level refs are automatically unwrapped in templates
Explanation
Templates unwrap top-level refs; nested refs inside plain objects are not unwrapped.
Step-by-step solution
- ref is returned to template.
- Template unwraps it.
Why the other options are wrong
- A. It is correct.
- B. Not eval.
- D. They are objects.
Question 4Easy
Which API makes a reactive object read-only for consumers?
- freeze()
- lock()
- const
- readonly()
Answer: D. readonly()
Explanation
readonly(obj) returns a proxy that warns on writes in development.
Step-by-step solution
- Pass the object to readonly.
- Writes are rejected with a warning.
Why the other options are wrong
- A. Not a Vue API (Object.freeze is plain JS).
- B. Not a Vue API.
- C. const only blocks reassignment of the variable.
Question 5Medium
What is triggerRef(r) used for?
- Creating a new ref that wraps a deep clone of the original value as a copy
- Forcing dependents of a shallowRef to update after an in-place mutation
- Resetting r to null
- Cancelling a watcher
Answer: B. Forcing dependents of a shallowRef to update after an in-place mutation
Explanation
It manually notifies subscribers when internals are changed without replacing .value.
Step-by-step solution
- Mutate in place.
- Call triggerRef.
Why the other options are wrong
- A. It does not create.
- C. It does not reset.
- D. It does not cancel.
Question 6Medium
What does markRaw(obj) do?
- Makes the object deeply reactive so that every nested property is tracked automatically
- Prevents the object from ever being turned into a reactive proxy
- Freezes the object with Object.freeze
- Creates a read-only copy
Answer: B. Prevents the object from ever being turned into a reactive proxy
Explanation
markRaw flags an object so Vue will not proxy it, useful for large third-party instances such as maps or charts.
Step-by-step solution
- Wrap the object in markRaw.
- Vue sets a skip flag.
- Later ref/reactive leaves it unproxied.
Why the other options are wrong
- A. That is the opposite.
- C. It sets a skip flag, not freeze.
- D. readonly() does that.
Question 7Medium
Given the code below, what is shown after inc() is called twice?
const n = ref(1)
function inc(){ n.value++ }
(template: {{ n }})
- 1
- 3
- 2
- [object Object]
Answer: B. 3
Explanation
Each n.value++ mutates the ref; the template shows the unwrapped value 1+2 = 3.
Step-by-step solution
- Start at 1.
- First call makes it 2.
- Second call makes it 3.
Why the other options are wrong
- A. Both increments update the ref.
- C. Only the first call would give 2.
- D. Templates unwrap the ref to a number.
Question 8Medium
Which utility converts each property of a reactive object into a ref that stays linked to the source?
- toRefs()
- toRaw()
- markRaw()
- unref()
Answer: A. toRefs()
Explanation
toRefs() creates refs linked to the original properties, so destructuring keeps reactivity.
Step-by-step solution
- toRefs() takes a reactive object.
- It returns an object where each property is a ref linked to the original property.
- So destructuring the result keeps the values reactive.
- The answer is toRefs() (option A).
Why the other options are wrong
- B. toRaw() returns the plain object without reactivity.
- C. markRaw() stops an object from being made reactive.
- D. unref() reads the value out of a ref; it does not create refs.
Tip: toRefs() is the tool for destructuring reactive objects without losing reactivity.
Question 9Hard
Which triggers reactivity in Vue 3 for a reactive array arr?
- arr[0] = 5 (index assignment)
- None of these; Vue 3 cannot detect writes by index, so use splice only
- Only arr.splice
- Only Vue.set(arr,0,5)
Answer: A. arr[0] = 5 (index assignment)
Explanation
Proxies track index writes, unlike Vue 2.
Step-by-step solution
- Vue 3 uses Proxy.
- Index set is trapped.
Why the other options are wrong
- B. Proxy detects it.
- C. Both work.
- D. Vue.set is removed.
Question 10Hard
Given const list = ref([1,2,3]), which statement triggers a re-render in Vue 3?
- list.push(4), because refs proxy array methods directly
- list.value.push(4)
- list = [1, 2, 3, 4], reassigning the variable
- list.length = 4, changing the ref's length
Answer: B. list.value.push(4)
Explanation
Mutating the array through .value is tracked; list.push fails since a ref is not an array, and reassigning a const throws.
Step-by-step solution
- List is a ref, so the array lives at list.value.
- list.value.push(4) changes that array through the ref.
- Vue tracks the change through .value and re-renders.
- So list.value.push(4) triggers a re-render (option B).
Why the other options are wrong
- A. A ref does not proxy array methods, so list.push is undefined.
- C. Const cannot be reassigned, so this throws and does not update the array.
- D. A ref has no length to change, so this does not update the array.
Tip: Read or mutate a ref's contents through .value in script code.
Practise all 21 questions free
The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.
Open this topic in the app →