Skip to content

Commit 866ae6c

Browse files
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 <[email protected]>
1 parent a584ff1 commit 866ae6c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

documentation/docs/03-template-syntax/03-each.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ title: {#each ...}
1212
{#each expression as name, index}...{/each}
1313
```
1414

15-
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`.
15+
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`.
16+
17+
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).
1618

1719
```svelte
1820
<h1>Shopping list</h1>

0 commit comments

Comments
 (0)