Skip to content

Commit 2c696de

Browse files
committed
Add a note about destructuring alignment. Closes #2.
1 parent 6547c34 commit 2c696de

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ LiteralMatchPattern :
5959
// number, string, boolean, null, or undefined literal
6060
```
6161

62+
The syntax of object and array patterns deliberately hews closely to destructuring which is advantageous for a couple reasons. First, it aligns with existing syntax that developers are familiar with. Second, it allows pattern matching and destructuring to be used in similar contexts (for example, future proposals for multi-methods or the like). However, pattern matching JavaScript values requires in practice requires more expressive power than simple destructuring gives us. This proposal adds additional patterns to fill the gaps. It may be reasonable to depart further from destructuring to increase the utility and expressiveness of this proposal (e.g. something like #17).
63+
6264
## Object Patterns
6365
Object patterns match objects with certain properties. Additional properties may be present on the matched object. Examples:
6466

0 commit comments

Comments
 (0)