Recall & Review
beginner
What does a reactive assignment in Svelte do?
A reactive assignment automatically updates the related parts of the UI when the variables it depends on change.
Click to reveal answer
beginner
How do you write a reactive assignment in Svelte?
Use the
$: label before an assignment, like $: doubled = count * 2;.Click to reveal answer
beginner
Why are reactive assignments useful in Svelte?
They keep the UI in sync with data changes without manually updating the DOM or writing extra code.
Click to reveal answer
intermediate
What happens if you assign a reactive variable inside a reactive statement in Svelte?
The reactive statement runs again whenever the variables it depends on change, triggering updates automatically.
Click to reveal answer
advanced
Can reactive assignments cause infinite loops? How to avoid them?
Yes, if a reactive assignment updates a variable it depends on. Avoid by not creating circular dependencies.
Click to reveal answer
What symbol starts a reactive assignment in Svelte?
✗ Incorrect
Reactive assignments in Svelte start with the
$: label.When does a reactive assignment update in Svelte?
✗ Incorrect
Reactive assignments update automatically whenever the variables they depend on change.
Which of these is a correct reactive assignment?
✗ Incorrect
The correct syntax uses
$: before the assignment.What can cause a reactive assignment to run repeatedly in a loop?
✗ Incorrect
Assigning a variable inside a reactive statement that depends on itself can cause infinite loops.
What is the main benefit of reactive assignments in Svelte?
✗ Incorrect
Reactive assignments keep the UI updated automatically when data changes.
Explain how reactive assignments work in Svelte and why they are useful.
Think about how Svelte tracks dependencies and updates the UI.
You got /3 concepts.
Describe a situation where a reactive assignment could cause an infinite loop and how to prevent it.
Consider what happens if a reactive statement changes a variable it watches.
You got /3 concepts.