docs: update #each to reflect support for null and undefined (#17339)

* docs: update #each to reflect support for null and undefined

* update

---------

Co-authored-by: Rich Harris <rich.harris@vercel.com>
pull/17347/head
Razin Shafayet 5 months ago committed by GitHub
parent a584ff1347
commit 866ae6cdc7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -12,7 +12,9 @@ title: {#each ...}
{#each expression as name, index}...{/each}
```
Iterating over values can be done with an each block. The values in question can be arrays, array-like objects (i.e. anything with a `length` property), or iterables like `Map` and `Set` — in other words, anything that can be used with `Array.from`.
Iterating over values can be done with an each block. The values in question can be arrays, array-like objects (i.e. anything with a `length` property), or iterables like `Map` and `Set`— in other words, anything that can be used with `Array.from`.
If the value is `null` or `undefined`, it is treated the same as an empty array (which will cause [else blocks](#Else-blocks) to be rendered, where applicable).
```svelte
<h1>Shopping list</h1>

Loading…
Cancel
Save