[{"id":"vuebeginner-001","courseId":"vue-beginner","domain":"reactivity","topic":"ref() and .value","prompt":"A teammate writes const count = ref(0) in a script. Inside a plain JavaScript function, which expression reads the current number?","hint":"The wrapper keeps the number under one named property.","explain":"A ref wraps a value in an object so Vue can notice reads and writes. Plain JavaScript code has to go through that wrapper to reach the number.","source":"https://vuejs.org/guide/essentials/reactivity-fundamentals.html#ref","interaction":{"type":"single"},"options":[{"id":"a","text":"count.value","why":"A ref keeps its number in the .value property, and JavaScript code must read and write through it."},{"id":"b","text":"count","whyNot":"That is the ref wrapper object, not the number; logging it shows { value: 0 }."},{"id":"c","text":"count()","whyNot":"A ref is an object with a .value property, not a function you can call."},{"id":"d","text":"count.current","whyNot":"Refs have no current property; the stored value sits under .value."}],"answer":"a","explanation":"ref() wraps a value in an object with a .value property; in JavaScript you read and write the value through .value.","concept":"ref() wraps a value in an object with a .value property; in JavaScript you read and write the value through .value.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["In script code, use .value on a ref; templates unwrap it for you."]},{"id":"vuebeginner-002","courseId":"vue-beginner","domain":"reactivity","topic":"Refs unwrapped in templates","prompt":"A <script setup> declares const user = { id: ref(1) }. The template renders {{ user.id + 1 }}. What appears on screen?","hint":"Look at how deep the ref sits inside the expression.","explain":"Templates let you skip .value, but that convenience only covers refs in certain positions. Check where the ref sits before predicting the rendered text.","source":"https://vuejs.org/guide/essentials/reactivity-fundamentals.html#ref","interaction":{"type":"single"},"options":[{"id":"a","text":"2","whyNot":"That would need user.id unwrapped, but only top-level refs are unwrapped in templates."},{"id":"b","text":"[object Object]1","why":"user.id is nested, so it stays a ref object; its string form is [object Object] and then 1 is appended."},{"id":"c","text":"1","whyNot":"A ref is unwrapped inside {{ }} only when it is the whole expression, not when it is part of + 1."},{"id":"d","text":"undefined","whyNot":"user.id exists; it is a ref object, not a missing value."}],"answer":"b","explanation":"Refs are unwrapped in templates only when they are top-level properties; a ref nested in a plain object stays a ref object.","concept":"Refs are unwrapped in templates only when they are top-level properties; a ref nested in a plain object stays a ref object.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["A ref nested inside a plain object needs .value, or must be destructured to the top level."]},{"id":"vuebeginner-003","courseId":"vue-beginner","domain":"reactivity","topic":"reactive() for objects","prompt":"A developer wraps state with reactive(). Which TWO statements about reactive() are true?","hint":"Think about the kinds of values it can wrap, and which object actually gets tracked.","explain":"reactive() makes an object itself reactive rather than wrapping a single value. Its rules cover what you can pass in and which object you keep using afterward.","source":"https://vuejs.org/guide/essentials/reactivity-fundamentals.html#reactive","interaction":{"type":"multiple","tellCount":true},"options":[{"id":"a","text":"It accepts objects, arrays, Map and Set, but not a primitive such as a string, number or boolean.","why":"reactive() only works for object types; primitive values need ref() instead."},{"id":"b","text":"Changing the original object you passed in does not trigger updates; you must change the returned proxy.","why":"Only the proxy is reactive, so mutations made through the original object are not tracked."},{"id":"c","text":"reactive(obj) returns a copy that is === to obj, so both variables behave the same.","whyNot":"The returned proxy is not equal to the original object, so the two are not ===."},{"id":"d","text":"reactive() only wraps the top level; nested objects stay plain and their changes are not tracked.","whyNot":"reactive() converts the object deeply, and nested objects are wrapped when they are accessed."},{"id":"e","text":"reactive() cannot wrap an array, because arrays are not plain objects.","whyNot":"Arrays are one of the object types that reactive() supports."},{"id":"f","text":"Calling reactive() on the same object again creates a new proxy, so you must store the first one.","whyNot":"Calling reactive() on the same object always returns the same proxy."}],"answer":"ab","explanation":"reactive() makes an object itself reactive as a Proxy; it only accepts object types, and only the proxy, not the original, is tracked.","concept":"reactive() makes an object itself reactive as a Proxy; it only accepts object types, and only the proxy, not the original, is tracked.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["Keep using the object reactive() returned, not the original you passed in."]},{"id":"vuebeginner-004","courseId":"vue-beginner","domain":"reactivity","topic":"Replacing a reactive object","prompt":"Your component keeps state in a reactive object and later reassigns or destructures it. Which TWO statements are true?","hint":"Vue follows property access on one specific object. Ask what a new object or a copied value does to that link.","explain":"Reactivity follows property access on one specific object. Pointing a variable at a different object, or pulling a value out of the object, can cut that link.","source":"https://vuejs.org/guide/essentials/reactivity-fundamentals.html#limitations-of-reactive","interaction":{"type":"multiple","tellCount":true},"options":[{"id":"a","text":"Assigning a new reactive({ count: 1 }) to a variable that held the old object breaks the link to the first object.","why":"The first object loses its reactivity connection, so changes to it no longer reach the component."},{"id":"b","text":"Destructuring a number property into a let variable, like let { count } = state, disconnects it from state.count.","why":"The destructured variable holds a plain number, so changing it leaves state.count alone."},{"id":"c","text":"Passing state.count into a function lets the function's parameter stay linked to state.count.","whyNot":"The function receives a plain number, so it cannot see later changes to state.count."},{"id":"d","text":"A ref stored as a property of a reactive object must be read with state.count.value.","whyNot":"A ref stored as a property of a reactive object is unwrapped, so state.count already gives the number."},{"id":"e","text":"reactive(0) works like ref(0), and you update the number through .value.","whyNot":"reactive() cannot hold a primitive number; use ref() for that."},{"id":"f","text":"Replacing state with a new reactive object keeps existing template bindings, since Vue matches them by variable name.","whyNot":"Vue tracks the object reference, not the variable name, so the first object's link is lost."}],"answer":"ab","explanation":"Reassigning a reactive variable or destructuring a primitive property cuts the reactivity connection, because Vue tracks property access on one object.","concept":"Reassigning a reactive variable or destructuring a primitive property cuts the reactivity connection, because Vue tracks property access on one object.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["Keep one reactive object and change its properties rather than replacing it."]},{"id":"vuebeginner-005","courseId":"vue-beginner","domain":"reactivity","topic":"Asynchronous DOM updates","prompt":"A button's handler runs count.value++ and then reads the text of a <span> that shows count, on the next line. What does the span show at that moment?","hint":"Think about when Vue writes the new markup to the page.","explain":"Changing state schedules a DOM update rather than applying it immediately. A helper lets you wait until the screen reflects the change.","source":"https://vuejs.org/guide/essentials/reactivity-fundamentals.html#dom-update-timing","interaction":{"type":"single"},"options":[{"id":"a","text":"The old text; Vue applies the update on the next tick, so await nextTick() waits for it.","why":"DOM updates are not applied synchronously; Vue buffers them until the next tick, and nextTick() resolves after they are applied."},{"id":"b","text":"The new text, because reactive changes update the DOM synchronously.","whyNot":"Vue buffers DOM updates until the next tick, so they are not applied synchronously."},{"id":"c","text":"The new text, but only if the change ran inside a watchEffect.","whyNot":"Any mutation of reactive state is buffered the same way; watchEffect plays no part in DOM timing."},{"id":"d","text":"Nothing changed, because count.value still holds 0 until the next render.","whyNot":"count.value holds the new number right away; only the rendered DOM waits for the next tick."}],"answer":"a","explanation":"DOM updates from state changes are buffered and applied at the next tick; nextTick() resolves once the DOM has been updated.","concept":"DOM updates from state changes are buffered and applied at the next tick; nextTick() resolves once the DOM has been updated.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["Read the DOM after await nextTick(), not right after changing state."]}]