Svelte · Middle · Question 54 of 75
Which statement about {#each} with destructuring is correct?
{#each items as { name, qty } (name)}
<input bind:value={qty} />
{/each}- ✓Correct answer: Binding to a destructured value doesn't update the item; use
item.qtyinstead - 2Destructuring is not allowed in
{#each} - 3It works and mutates the item
Explanation
Svelte's best practices advise avoiding destructuring when you need to mutate the item.