> For the complete documentation index, see [llms.txt](https://132oq-szjxckld--diwejk1k2j-1123n.gitbook.io/documentation-studio-shento/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://132oq-szjxckld--diwejk1k2j-1123n.gitbook.io/documentation-studio-shento/getting-started-with-sveltekit/working-with-conditionals-and-loops/lists-and-keys.md).

# Lists & Keys

When manipulating lists, it's good practice to add an key (identifier), when you loop through that list with `#each`. This will help Svelte identity the item in the list, and avoid issues.

<pre class="language-html"><code class="lang-html"><strong>{#each [name-array] as [item-array], [index-key] (item-array.key)}
</strong>		&#x3C;p>{index}&#x3C;/p>
		&#x3C;p>{item.id}&#x3C;/p>
		&#x3C;p>{item.name}&#x3C;/p>
{/each}
---
&#x3C;script>
	let sampleArray = [
		{ id: 1, name: 'John Doe' },
		{ id: 2, name: 'Jane Doe' },
		{ id: 3, name: 'John Smith' },
		{ id: 4, name: 'Jane Smith' },
		{ id: 5, name: 'John Brown' },
	];
&#x3C;/script>

&#x3C;main>
<strong>	{#each sampleArray as item, index (item.id)}
</strong>		&#x3C;p>{index}&#x3C;/p>
		&#x3C;p>{item.id}&#x3C;/p>
		&#x3C;p>{item.name}&#x3C;/p>
	{/each}
&#x3C;/main>
</code></pre>

{% hint style="info" %}
The identifier must be unique, or else there will be issues.
{% endhint %}
