Svelte · Junior · Question 19 of 76

Why shouldn't you use the index as the key in {#each}?

Explanation

Use a stable unique identifier like item.id. The index is available as the second variable: {#each items as item, i (item.id)}.

Further reading

Problem with a question

Svelte · Junior · question 19

Test yourself

Take the Svelte · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz