All quizzesMedium
shallowRef & markRaw
Preview — 3 of 10 questions
When should you use shallowRef instead of ref?
AWhen the ref value is a primitive (number, string) — shallowRef is faster for primitives
BWhen you want the ref to be accessible globally without .value
CshallowRef is deprecated in Vue 3 — always use ref
DWhen you have a large object or array where you only need to track the top-level reference change, not nested property mutations
What is the difference between reactive and shallowReactive?
Areactive deeply proxies all nested objects; shallowReactive only makes top-level properties reactive — nested objects remain plain
BshallowReactive is faster for all use cases — it should always be preferred
CshallowReactive works with arrays; reactive does not support arrays
DshallowReactive is only available in Vue 3.3+
What does markRaw() do and when should you use it?
AIt marks an object as immutable — Vue cannot modify it
BIt prevents the object from being garbage collected
CIt converts a reactive object back to a plain JavaScript object
DIt marks an object as non-reactive — Vue will never wrap it in a Proxy, even if it ends up in reactive state
Sign up free to play
Answer all 10 questions (7 more), see explanations for every answer, and track your score.