-
Notifications
You must be signed in to change notification settings - Fork 89
/
index.html
3309 lines (3093 loc) · 410 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<head><meta charset="utf-8"><meta property="og:image" content="https://tc39.es/ecmarkup/ecma-logo.png"><meta property="og:title" content="Pattern Matching"><meta property="og:description" content="Welcome
TODOs
Scope and bindings
Basic case.
Work with `for` loop (CreatePerIterationEnvironment).
Work with function parameters.
Introduction
This specification consists of the following pa">
<title>Pattern Matching</title><script src="assets/ecmarkup.js?cache=rh3pBrXc" defer=""></script><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.0.1/styles/base16/solarized-light.min.css"><link rel="stylesheet" href="assets/ecmarkup.css"><link rel="stylesheet" href="assets/print.css" media="print"><style>
@media print {
@page :left {
@bottom-right {
content: '© Ecma International 2024';
}
}
@page :right {
@bottom-left {
content: '© Ecma International 2024';
}
}
@page :first {
@bottom-left {
content: '';
}
@bottom-right {
content: '';
}
}
@page :blank {
@bottom-left {
content: '';
}
@bottom-right {
content: '';
}
}
}
</style></head><body><div id="shortcuts-help">
<ul>
<li><span>Toggle shortcuts help</span><code>?</code></li>
<li><span>Toggle "can call user code" annotations</span><code>u</code></li>
<li><span>Jump to search box</span><code>/</code></li>
<li><span>Toggle pinning of the current clause</span><code>p</code></li>
<li><span>Jump to <i>n</i>th pin</span><code>1-9</code></li>
</ul></div><div id="menu-toggle"><svg xmlns="http://www.w3.org/2000/svg" style="width:100%; height:100%; stroke:currentColor" viewBox="0 0 120 120" width="54" height="54">
<title>Menu</title>
<path stroke-width="10" stroke-linecap="round" d="M30,60 h60 M30,30 m0,5 h60 M30,90 m0,-5 h60"></path>
</svg></div><div id="menu-spacer" class="menu-spacer"></div><div id="menu"><div id="menu-search"><input type="text" id="menu-search-box" placeholder="Search..."><div id="menu-search-results" class="inactive"></div></div><div id="menu-pins"><div class="menu-pane-header">Pins<button class="unpin-all">clear</button></div><ul id="menu-pins-list"></ul></div><div class="menu-pane-header">Table of Contents</div><div id="menu-toc"><ol class="toc"><li><span class="item-toggle">+</span><a href="#welcome" title="Welcome">Welcome</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-todos" title="TODOs">TODOs</a></li><li><span class="item-toggle-none"></span><a href="#sec-nav" title="Introduction">Introduction</a></li><li><span class="item-toggle-none"></span><a href="#sec-notes-layering" title="Layering">Layering</a></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-overview" title="Overview"><span class="secnum">4</span> Overview</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-organization-of-this-specification" title="Organization of This Specification"><span class="secnum">4.5</span> Organization of This Specification</a></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-ecmascript-data-types-and-values" title="ECMAScript Data Types and Values"><span class="secnum">6</span> ECMAScript Data Types and Values</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-ecmascript-language-types" title="ECMAScript Language Types"><span class="secnum">6.1</span> ECMAScript Language Types</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-ecmascript-language-types-symbol-type" title="The Symbol Type"><span class="secnum">6.1.5</span> The Symbol Type</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-well-known-symbols" title="Well-Known Symbols"><span class="secnum">6.1.5.1</span> Well-Known Symbols</a></li></ol></li><li><span class="item-toggle-none"></span><a href="#sec-object-internal-methods-and-internal-slots" title="Object Internal Methods and Internal Slots"><span class="secnum">6.1.7</span> Object Internal Methods and Internal Slots</a></li></ol></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-abstract-operations" title="Abstract Operations"><span class="secnum">7</span> Abstract Operations</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-operations-on-objects" title="Operations on Objects"><span class="secnum">7.3</span> Operations on Objects</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-initializeinstance" title="InitializeInstanceElements ( O, constructor )"><span class="secnum">7.3.34</span> InitializeInstanceElements ( <var>O</var>, <var>constructor</var> )</a></li></ol></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-syntax-directed-operations" title="Syntax-Directed Operations"><span class="secnum">8</span> Syntax-Directed Operations</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-syntax-directed-operations-scope-analysis" title="Scope Analysis"><span class="secnum">8.2</span> Scope Analysis</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-static-semantics-boundnames" title="Static Semantics: BoundNames"><span class="secnum">8.2.1</span> SS: BoundNames</a></li><li><span class="item-toggle-none"></span><a href="#sec-static-semantics-declarationpart" title="Static Semantics: DeclarationPart"><span class="secnum">8.2.2</span> SS: DeclarationPart</a></li><li><span class="item-toggle-none"></span><a href="#sec-static-semantics-isconstantdeclaration" title="Static Semantics: IsConstantDeclaration"><span class="secnum">8.2.3</span> SS: IsConstantDeclaration</a></li><li><span class="item-toggle-none"></span><a href="#sec-static-semantics-lexicallydeclarednames" title="Static Semantics: LexicallyDeclaredNames"><span class="secnum">8.2.4</span> SS: LexicallyDeclaredNames</a></li><li><span class="item-toggle-none"></span><a href="#sec-static-semantics-lexicallyscopeddeclarations" title="Static Semantics: LexicallyScopedDeclarations"><span class="secnum">8.2.5</span> SS: LexicallyScopedDeclarations</a></li><li><span class="item-toggle-none"></span><a href="#sec-static-semantics-vardeclarednames" title="Static Semantics: VarDeclaredNames"><span class="secnum">8.2.6</span> SS: VarDeclaredNames</a></li><li><span class="item-toggle-none"></span><a href="#sec-static-semantics-varscopeddeclarations" title="Static Semantics: VarScopedDeclarations"><span class="secnum">8.2.7</span> SS: VarScopedDeclarations</a></li><li><span class="item-toggle-none"></span><a href="#sec-static-semantics-toplevellexicallydeclarednames" title="Static Semantics: TopLevelLexicallyDeclaredNames"><span class="secnum">8.2.8</span> SS: TopLevelLexicallyDeclaredNames</a></li><li><span class="item-toggle-none"></span><a href="#sec-static-semantics-toplevellexicallyscopeddeclarations" title="Static Semantics: TopLevelLexicallyScopedDeclarations"><span class="secnum">8.2.9</span> SS: TopLevelLexicallyScopedDeclarations</a></li><li><span class="item-toggle-none"></span><a href="#sec-static-semantics-toplevelvardeclarednames" title="Static Semantics: TopLevelVarDeclaredNames"><span class="secnum">8.2.10</span> SS: TopLevelVarDeclaredNames</a></li><li><span class="item-toggle-none"></span><a href="#sec-static-semantics-toplevelvarscopeddeclarations" title="Static Semantics: TopLevelVarScopedDeclarations"><span class="secnum">8.2.11</span> SS: TopLevelVarScopedDeclarations</a></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-syntax-directed-operations-miscellaneous" title="Miscellaneous"><span class="secnum">8.6</span> Miscellaneous</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-runtime-semantics-bindinginitialization" title="Runtime Semantics: BindingInitialization"><span class="secnum">8.6.2</span> RS: BindingInitialization</a></li><li><span class="item-toggle-none"></span><a href="#sec-runtime-semantics-iteratorbindinginitialization" title="Runtime Semantics: IteratorBindingInitialization"><span class="secnum">8.6.3</span> RS: IteratorBindingInitialization</a></li></ol></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-executable-code-and-execution-contexts" title="Executable Code and Execution Contexts"><span class="secnum">9</span> Executable Code and Execution Contexts</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-weakly-hold-targets-processing-model" title="Processing Model of WeakRef and FinalizationRegistryweakly hold Targets"><span class="secnum">9.10</span> Processing Model of <del>WeakRef and FinalizationRegistry</del><ins>weakly hold</ins> Targets</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-weakly-hold-execution" title="Execution"><span class="secnum">9.10.3</span> Execution</a></li></ol></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-ecmascript-language-lexical-grammar" title="ECMAScript Language: Lexical Grammar"><span class="secnum">12</span> ECMAScript Language: Lexical Grammar</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-automatic-semicolon-insertion" title="Automatic Semicolon Insertion"><span class="secnum">12.10</span> Automatic Semicolon Insertion</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-rules-of-automatic-semicolon-insertion" title="Rules of Automatic Semicolon Insertion"><span class="secnum">12.10.1</span> Rules of Automatic Semicolon Insertion</a></li><li><span class="item-toggle">+</span><a href="#sec-interesting-cases-of-automatic-semicolon-insertion" title="Interesting Cases of Automatic Semicolon Insertion"><span class="secnum">12.10.3</span> Interesting Cases of Automatic Semicolon Insertion</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-asi-cases-with-no-lineterminator-here" title="Cases of Automatic Semicolon Insertion and “[no LineTerminator here]”"><span class="secnum">12.10.3.2</span> Cases of Automatic Semicolon Insertion and “[no <emu-nt>LineTerminator</emu-nt> here]”</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-no-lineterminator-here-automatic-semicolon-insertion-list" title="List of Grammar Productions with Optional Operands and “[no LineTerminator here]”"><span class="secnum">12.10.3.2.1</span> List of Grammar Productions with Optional Operands and “[no <emu-nt>LineTerminator</emu-nt> here]”</a></li></ol></li></ol></li></ol></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-ecmascript-language-expressions" title="ECMAScript Language: Expressions"><span class="secnum">13</span> ECMAScript Language: Expressions</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-primary-expression" title="Primary Expression"><span class="secnum">13.2</span> Primary Expression</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-primary-expression-match-expression" title="Match Expression"><span class="secnum">13.2.10</span> Match Expression</a></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-relational-operators" title="Relational Operators"><span class="secnum">13.10</span> Relational Operators</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-relational-operators-runtime-semantics-evaluation" title="Runtime Semantics: Evaluation"><span class="secnum">13.10.1</span> RS: Evaluation</a></li></ol></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-ecmascript-language-statements-and-declarations" title="ECMAScript Language: Statements and Declarations"><span class="secnum">14</span> ECMAScript Language: Statements and Declarations</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-iteration-statements" title="Iteration Statements"><span class="secnum">14.7</span> Iteration Statements</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-for-in-and-for-of-statements" title="The for-in, for-of, and for-await-of Statements"><span class="secnum">14.7.1</span> The <code>for</code>-<code>in</code>, <code>for</code>-<code>of</code>, and <code>for</code>-<code>await</code>-<code>of</code> Statements</a></li></ol></li><li><span class="item-toggle-none"></span><a href="#sec-try-statement" title="The try Statement"><span class="secnum">14.14</span> The <code>try</code> Statement</a></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-ecmascript-language-functions-and-classes" title="ECMAScript Language: Functions and Classes"><span class="secnum">15</span> ECMAScript Language: Functions and Classes</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-class-definitions" title="Class Definitions"><span class="secnum">15.7</span> Class Definitions</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-runtime-semantics-classdefinitionevaluation" title="Runtime Semantics: ClassDefinitionEvaluation"><span class="secnum">15.7.14</span> RS: ClassDefinitionEvaluation</a></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-tail-position-calls" title="Tail Position Calls"><span class="secnum">15.10</span> Tail Position Calls</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-static-semantics-hascallintailposition" title="Static Semantics: HasCallInTailPosition"><span class="secnum">15.10.2</span> SS: HasCallInTailPosition</a></li></ol></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-fundamental-objects" title="Fundamental Objects"><span class="secnum">20</span> Fundamental Objects</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-object-objects" title="Object Objects"><span class="secnum">20.1</span> Object Objects</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-properties-of-the-object-constructor" title="Properties of the Object Constructor"><span class="secnum">20.1.2</span> Properties of the Object Constructor</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-object-%symbol.custommatcher%" title="Object [ %Symbol.customMatcher% ] ( subject, hint )"><span class="secnum">20.1.2.24</span> Object [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</a></li></ol></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-function-objects" title="Function Objects"><span class="secnum">20.2</span> Function Objects</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-properties-of-the-function-constructor" title="Properties of the Function Constructor"><span class="secnum">20.2.2</span> Properties of the Function Constructor</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-function-%symbol.custommatcher%" title="Function [ %Symbol.customMatcher% ] ( subject, hint )"><span class="secnum">20.2.2.2</span> Function [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</a></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-properties-of-the-function-prototype-object" title="Properties of the Function Prototype Object"><span class="secnum">20.2.3</span> Properties of the Function Prototype Object</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-function.prototype-%symbol.custommatcher%" title="Function.prototype [ %Symbol.customMatcher% ] ( subject, hint, receiver )"><span class="secnum">20.2.3.7</span> Function.prototype [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var>, <var>receiver</var> )</a></li></ol></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-boolean-objects" title="Boolean Objects"><span class="secnum">20.3</span> Boolean Objects</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-properties-of-the-boolean-constructor" title="Properties of the Boolean Constructor"><span class="secnum">20.3.2</span> Properties of the Boolean Constructor</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-boolean-%symbol.custommatcher%" title="Boolean [ %Symbol.customMatcher% ] ( subject, hint )"><span class="secnum">20.3.2.2</span> Boolean [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</a></li></ol></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-symbol-objects" title="Symbol Objects"><span class="secnum">20.4</span> Symbol Objects</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-properties-of-the-symbol-constructor" title="Properties of the Symbol Constructor"><span class="secnum">20.4.2</span> Properties of the Symbol Constructor</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-symbol.custommatcher" title="Symbol.customMatcher"><span class="secnum">20.4.2.17</span> Symbol.customMatcher</a></li><li><span class="item-toggle-none"></span><a href="#sec-symbol-%symbol.custommatcher%" title="Symbol [ %Symbol.customMatcher% ] ( subject, hint )"><span class="secnum">20.4.2.18</span> Symbol [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</a></li></ol></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-error-objects" title="Error Objects"><span class="secnum">20.5</span> Error Objects</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-error-constructor" title="The Error Constructor"><span class="secnum">20.5.1</span> The Error Constructor</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-error-message" title="Error ( message [ , options ] )"><span class="secnum">20.5.1.1</span> Error ( <var>message</var> [ , <var>options</var> ] )</a></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-properties-of-the-error-constructors" title="Properties of the Error Constructor"><span class="secnum">20.5.2</span> Properties of the Error Constructor</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-error-%symbol.custommatcher%" title="Error [ %Symbol.customMatcher% ] ( subject, hint )"><span class="secnum">20.5.2.2</span> Error [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</a></li></ol></li><li><span class="item-toggle-none"></span><a href="#sec-properties-of-error-instances" title="Properties of Error Instances"><span class="secnum">20.5.4</span> Properties of Error Instances</a></li><li><span class="item-toggle">+</span><a href="#sec-nativeerror-object-structure" title="NativeError Object Structure"><span class="secnum">20.5.6</span> <var>NativeError</var> Object Structure</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-nativeerror-constructors" title="The NativeError Constructors"><span class="secnum">20.5.6.1</span> The <var>NativeError</var> Constructors</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-nativeerror" title="NativeError ( message [ , options ] )"><span class="secnum">20.5.6.1.1</span> <var>NativeError</var> ( <var>message</var> [ , <var>options</var> ] )</a></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-properties-of-the-nativeerror-constructors" title="Properties of the NativeError Constructors"><span class="secnum">20.5.6.2</span> Properties of the <var>NativeError</var> Constructors</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-nativeerror-%symbol.custommatcher%" title="NativeError [ %Symbol.customMatcher% ] ( subject, hint )"><span class="secnum">20.5.6.2.2</span> <var>NativeError</var> [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</a></li></ol></li><li><span class="item-toggle-none"></span><a href="#sec-properties-of-nativeerror-instances" title="Properties of NativeError Instances"><span class="secnum">20.5.6.4</span> Properties of <var>NativeError</var> Instances</a></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-aggregate-error-objects" title="AggregateError Objects"><span class="secnum">20.5.7</span> AggregateError Objects</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-aggregate-error-constructor" title="The AggregateError Constructor"><span class="secnum">20.5.7.1</span> The AggregateError Constructor</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-aggregate-error" title="AggregateError ( errors, message [ , options ] )"><span class="secnum">20.5.7.1.1</span> AggregateError ( <var>errors</var>, <var>message</var> [ , <var>options</var> ] )</a></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-properties-of-the-aggregate-error-constructors" title="Properties of the AggregateError Constructor"><span class="secnum">20.5.7.2</span> Properties of the AggregateError Constructor</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-aggregate-error-%symbol.custommatcher%" title="AggregateError [ %Symbol.customMatcher% ] ( subject, hint )"><span class="secnum">20.5.7.2.2</span> AggregateError [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</a></li></ol></li><li><span class="item-toggle-none"></span><a href="#sec-properties-of-aggregate-error-instances" title="Properties of AggregateError Instances"><span class="secnum">20.5.7.4</span> Properties of AggregateError Instances</a></li></ol></li></ol></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-numbers-and-dates" title="Numbers and Dates"><span class="secnum">21</span> Numbers and Dates</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-number-objects" title="Number Objects"><span class="secnum">21.1</span> Number Objects</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-properties-of-the-number-constructor" title="Properties of the Number Constructor"><span class="secnum">21.1.2</span> Properties of the Number Constructor</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-number-%symbol.custommatcher%" title="Number [ %Symbol.customMatcher% ] ( subject, hint )"><span class="secnum">21.1.2.16</span> Number [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</a></li></ol></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-bigint-objects" title="BigInt Objects"><span class="secnum">21.2</span> BigInt Objects</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-properties-of-the-bigint-constructor" title="Properties of the BigInt Constructor"><span class="secnum">21.2.2</span> Properties of the BigInt Constructor</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-bigint-%symbol.custommatcher%" title="BigInt [ %Symbol.customMatcher% ] ( subject, hint )"><span class="secnum">21.2.2.4</span> BigInt [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</a></li></ol></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-date-objects" title="Date Objects"><span class="secnum">21.4</span> Date Objects</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-properties-of-the-date-constructor" title="Properties of the Date Constructor"><span class="secnum">21.4.3</span> Properties of the Date Constructor</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-date-%symbol.custommatcher%" title="Date [ %Symbol.customMatcher% ] ( subject, hint )"><span class="secnum">21.4.3.5</span> Date [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</a></li></ol></li></ol></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-text-processing" title="Text Processing"><span class="secnum">22</span> Text Processing</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-string-objects" title="String Objects"><span class="secnum">22.1</span> String Objects</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-properties-of-the-string-constructor" title="Properties of the String Constructor"><span class="secnum">22.1.2</span> Properties of the String Constructor</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-string-%symbol.custommatcher%" title="String [ %Symbol.customMatcher% ] ( subject, hint )"><span class="secnum">22.1.2.5</span> String [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</a></li></ol></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-regexp-regular-expression-objects" title="RegExp (Regular Expression) Objects"><span class="secnum">22.2</span> RegExp (Regular Expression) Objects</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-properties-of-the-regexp-constructor" title="Properties of the RegExp Constructor"><span class="secnum">22.2.5</span> Properties of the RegExp Constructor</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-regexp-%symbol.custommatcher%" title="RegExp [ %Symbol.customMatcher% ] ( subject, hint )"><span class="secnum">22.2.5.3</span> RegExp [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</a></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-properties-of-the-regexp-prototype-object" title="Properties of the RegExp Prototype Object"><span class="secnum">22.2.6</span> Properties of the RegExp Prototype Object</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-regexp.prototype-%symbol.custommatcher%" title="RegExp.prototype [ %Symbol.customMatcher% ] ( subject, hint )"><span class="secnum">22.2.6.20</span> RegExp.prototype [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</a></li></ol></li></ol></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-indexed-collections" title="Indexed Collections"><span class="secnum">23</span> Indexed Collections</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-array-objects" title="Array Objects"><span class="secnum">23.1</span> Array Objects</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-properties-of-the-array-constructor" title="Properties of the Array Constructor"><span class="secnum">23.1.2</span> Properties of the Array Constructor</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-array-%symbol.custommatcher%" title="Array [ %Symbol.customMatcher% ] ( subject, hint )"><span class="secnum">23.1.2.6</span> Array [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</a></li></ol></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-typedarray-objects" title="TypedArray Objects"><span class="secnum">23.2</span> TypedArray Objects</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-properties-of-the-typedarray-constructors" title="Properties of the TypedArray Constructors"><span class="secnum">23.2.6</span> Properties of the <var>TypedArray</var> Constructors</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-_typedarray_-%symbol.custommatcher%" title="TypedArray [ %Symbol.customMatcher% ] ( subject, hint )"><span class="secnum">23.2.6.3</span> <var>TypedArray</var> [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</a></li></ol></li></ol></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-keyed-collections" title="Keyed Collections"><span class="secnum">24</span> Keyed Collections</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-map-objects" title="Map Objects"><span class="secnum">24.1</span> Map Objects</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-properties-of-the-map-constructor" title="Properties of the Map Constructor"><span class="secnum">24.1.2</span> Properties of the Map Constructor</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-map-%symbol.custommatcher%" title="Map [ %Symbol.customMatcher% ] ( subject, hint )"><span class="secnum">24.1.2.3</span> Map [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</a></li></ol></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-set-objects" title="Set Objects"><span class="secnum">24.2</span> Set Objects</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-properties-of-the-set-constructor" title="Properties of the Set Constructor"><span class="secnum">24.2.2</span> Properties of the Set Constructor</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-set-%symbol.custommatcher%" title="Set [ %Symbol.customMatcher% ] ( subject, hint )"><span class="secnum">24.2.2.3</span> Set [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</a></li></ol></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-weakmap-objects" title="WeakMap Objects"><span class="secnum">24.3</span> WeakMap Objects</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-properties-of-the-weakmap-constructor" title="Properties of the WeakMap Constructor"><span class="secnum">24.3.2</span> Properties of the WeakMap Constructor</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-weakmap-%symbol.custommatcher%" title="WeakMap [ %Symbol.customMatcher% ] ( subject, hint )"><span class="secnum">24.3.2.2</span> WeakMap [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</a></li></ol></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-weakset-objects" title="WeakSet Objects"><span class="secnum">24.4</span> WeakSet Objects</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-properties-of-the-weakset-constructor" title="Properties of the WeakSet Constructor"><span class="secnum">24.4.2</span> Properties of the WeakSet Constructor</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-weakset-%symbol.custommatcher%" title="WeakSet [ %Symbol.customMatcher% ] ( subject, hint )"><span class="secnum">24.4.2.2</span> WeakSet [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</a></li></ol></li></ol></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-structured-data" title="Structured Data"><span class="secnum">25</span> Structured Data</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-arraybuffer-objects" title="ArrayBuffer Objects"><span class="secnum">25.1</span> ArrayBuffer Objects</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-properties-of-the-arraybuffer-constructor" title="Properties of the ArrayBuffer Constructor"><span class="secnum">25.1.5</span> Properties of the ArrayBuffer Constructor</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-arraybuffer-%symbol.custommatcher%" title="ArrayBuffer [ %Symbol.customMatcher% ] ( subject, hint )"><span class="secnum">25.1.5.4</span> ArrayBuffer [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</a></li></ol></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-sharedarraybuffer-objects" title="SharedArrayBuffer Objects"><span class="secnum">25.2</span> SharedArrayBuffer Objects</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-properties-of-the-sharedarraybuffer-constructor" title="Properties of the SharedArrayBuffer Constructor"><span class="secnum">25.2.4</span> Properties of the SharedArrayBuffer Constructor</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-sharedarraybuffer-%symbol.custommatcher%" title="SharedArrayBuffer [ %Symbol.customMatcher% ] ( subject, hint )"><span class="secnum">25.2.4.3</span> SharedArrayBuffer [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</a></li></ol></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-dataview-objects" title="DataView Objects"><span class="secnum">25.3</span> DataView Objects</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-properties-of-the-dataview-constructor" title="Properties of the DataView Constructor"><span class="secnum">25.3.3</span> Properties of the DataView Constructor</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-dataview-%symbol.custommatcher%" title="DataView [ %Symbol.customMatcher% ] ( subject, hint )"><span class="secnum">25.3.3.2</span> DataView [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</a></li></ol></li></ol></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-managing-memory" title="Managing Memory"><span class="secnum">26</span> Managing Memory</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-weak-ref-objects" title="WeakRef Objects"><span class="secnum">26.1</span> WeakRef Objects</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-properties-of-the-weak-ref-constructor" title="Properties of the WeakRef Constructor"><span class="secnum">26.1.2</span> Properties of the WeakRef Constructor</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-weakref-%symbol.custommatcher%" title="WeakRef [ %Symbol.customMatcher% ] ( subject, hint )"><span class="secnum">26.1.2.2</span> WeakRef [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</a></li></ol></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-finalization-registry-objects" title="FinalizationRegistry Objects"><span class="secnum">26.2</span> FinalizationRegistry Objects</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-properties-of-the-finalization-registry-constructor" title="Properties of the FinalizationRegistry Constructor"><span class="secnum">26.2.2</span> Properties of the FinalizationRegistry Constructor</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-finalizationregistry-%symbol.custommatcher%" title="FinalizationRegistry [ %Symbol.customMatcher% ] ( subject, hint )"><span class="secnum">26.2.2.2</span> FinalizationRegistry [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</a></li></ol></li></ol></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-control-abstraction-objects" title="Control Abstraction Objects"><span class="secnum">27</span> Control Abstraction Objects</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-promise-objects" title="Promise Objects"><span class="secnum">27.2</span> Promise Objects</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-properties-of-the-promise-constructor" title="Properties of the Promise Constructor"><span class="secnum">27.2.4</span> Properties of the Promise Constructor</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-promise-%symbol.custommatcher%" title="Promise [ %Symbol.customMatcher% ] ( subject, hint )"><span class="secnum">27.2.4.9</span> Promise [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</a></li></ol></li></ol></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-reflection" title="Reflection"><span class="secnum">28</span> Reflection</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-proxy-objects" title="Proxy Objects"><span class="secnum">28.2</span> Proxy Objects</a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-proxy-constructor" title="The Proxy Constructor"><span class="secnum">28.2.1</span> The Proxy Constructor</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-proxy-%symbol.custommatcher%" title="Proxy [ %Symbol.customMatcher% ] ( )"><span class="secnum">28.2.1.2</span> Proxy [ %Symbol.customMatcher% ] ( )</a></li></ol></li></ol></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-pattern-matching" title="Pattern Matching"><span class="secnum">30</span> <ins>Pattern Matching</ins></a><ol class="toc"><li><span class="item-toggle">+</span><a href="#sec-match-patterns" title="Match Patterns"><span class="secnum">30.1</span> Match Patterns</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-match-patterns-static-semantics-early-errors" title="Static Semantics: Early Errors"><span class="secnum">30.1.1</span> SS: Early Errors</a></li><li><span class="item-toggle-none"></span><a href="#sec-is-optional-pattern" title="Static Semantics: IsOptionalPattern"><span class="secnum">30.1.2</span> SS: IsOptionalPattern</a></li><li><span class="item-toggle-none"></span><a href="#sec-match-pattern-matches" title="Runtime Semantics: MatchPatternMatches"><span class="secnum">30.1.3</span> RS: MatchPatternMatches</a></li><li><span class="item-toggle-none"></span><a href="#sec-primitive-pattern-matches" title="Runtime Semantics: PrimitivePatternMatches"><span class="secnum">30.1.4</span> RS: PrimitivePatternMatches</a></li><li><span class="item-toggle-none"></span><a href="#sec-variable-declaration-pattern-matches" title="Runtime Semantics: VariableDeclarationPatternMatches"><span class="secnum">30.1.5</span> RS: VariableDeclarationPatternMatches</a></li><li><span class="item-toggle-none"></span><a href="#sec-member-expression-pattern-matches" title="Runtime Semantics: MemberExpressionPatternMatches"><span class="secnum">30.1.6</span> RS: MemberExpressionPatternMatches</a></li><li><span class="item-toggle-none"></span><a href="#sec-object-pattern-matches" title="Runtime Semantics: ObjectPatternMatches"><span class="secnum">30.1.7</span> RS: ObjectPatternMatches</a></li><li><span class="item-toggle-none"></span><a href="#sec-object-pattern-inner-matches" title="Runtime Semantics: ObjectPatternInnerMatches"><span class="secnum">30.1.8</span> RS: ObjectPatternInnerMatches</a></li><li><span class="item-toggle-none"></span><a href="#sec-array-pattern-matches" title="Runtime Semantics: ArrayPatternMatches"><span class="secnum">30.1.9</span> RS: ArrayPatternMatches</a></li><li><span class="item-toggle-none"></span><a href="#sec-list-pattern-matches" title="Runtime Semantics: ListPatternMatches"><span class="secnum">30.1.10</span> RS: ListPatternMatches</a></li><li><span class="item-toggle-none"></span><a href="#sec-list-pattern-inner-matches" title="Runtime Semantics: ListPatternInnerMatches"><span class="secnum">30.1.11</span> RS: ListPatternInnerMatches</a></li><li><span class="item-toggle-none"></span><a href="#sec-unary-algebraic-pattern-matches" title="Runtime Semantics: UnaryAlgebraicPatternMatches"><span class="secnum">30.1.12</span> RS: UnaryAlgebraicPatternMatches</a></li><li><span class="item-toggle-none"></span><a href="#sec-relational-pattern-matches" title="Runtime Semantics: RelationalPatternMatches"><span class="secnum">30.1.13</span> RS: RelationalPatternMatches</a></li><li><span class="item-toggle-none"></span><a href="#sec-if-pattern-matches" title="Runtime Semantics: IfPatternMatches"><span class="secnum">30.1.14</span> RS: IfPatternMatches</a></li><li><span class="item-toggle-none"></span><a href="#sec-combined-match-pattern-matches" title="Runtime Semantics: CombinedMatchPatternMatches"><span class="secnum">30.1.15</span> RS: CombinedMatchPatternMatches</a></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-match-expression" title="The match Expression"><span class="secnum">30.2</span> The <code>match</code> Expression</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-match-expression-static-semantics-early-errors" title="Static Semantics: Early Errors"><span class="secnum">30.2.1</span> SS: Early Errors</a></li><li><span class="item-toggle-none"></span><a href="#sec-match-expression-runtime-semantics-evaluation" title="Runtime Semantics: Evaluation"><span class="secnum">30.2.2</span> RS: Evaluation</a></li><li><span class="item-toggle-none"></span><a href="#sec-match-expression-clauses-runtime-semantics-evaluation" title="Runtime Semantics: MatchExpressionClausesEvaluation"><span class="secnum">30.2.3</span> RS: MatchExpressionClausesEvaluation</a></li><li><span class="item-toggle-none"></span><a href="#sec-match-expression-clause-runtime-semantics-evaluation" title="Runtime Semantics: MatchExpressionClauseEvaluation"><span class="secnum">30.2.4</span> RS: MatchExpressionClauseEvaluation</a></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-abstract-operations-for-pattern-matching" title="Abstract Operations for Pattern Matching"><span class="secnum">30.3</span> Abstract Operations for Pattern Matching</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-invoke-custom-matcher" title="InvokeCustomMatcher ( matcher, subject, cacheGroup, kind, receiver )"><span class="secnum">30.3.1</span> InvokeCustomMatcher ( <var>matcher</var>, <var>subject</var>, <var>cacheGroup</var>, <var>kind</var>, <var>receiver</var> )</a></li><li><span class="item-toggle-none"></span><a href="#sec-validatecustommatcherhint" title="ValidateCustomMatcherHint ( hint [ , kind ] )"><span class="secnum">30.3.2</span> ValidateCustomMatcherHint ( <var>hint</var> [ , <var>kind</var> ] )</a></li><li><span class="item-toggle-none"></span><a href="#sec-creatematchcache" title="CreateMatchCache ( )"><span class="secnum">30.3.3</span> CreateMatchCache ( )</a></li><li><span class="item-toggle-none"></span><a href="#sec-get-match-cache" title="GetMatchCache ( subject, cacheGroup )"><span class="secnum">30.3.4</span> GetMatchCache ( <var>subject</var>, <var>cacheGroup</var> )</a></li><li><span class="item-toggle-none"></span><a href="#sec-has-property-cached" title="HasPropertyCached ( subject, cacheGroup, propertyName )"><span class="secnum">30.3.5</span> HasPropertyCached ( <var>subject</var>, <var>cacheGroup</var>, <var>propertyName</var> )</a></li><li><span class="item-toggle-none"></span><a href="#sec-get-cached" title="GetCached ( subject, cacheGroup, propertyName )"><span class="secnum">30.3.6</span> GetCached ( <var>subject</var>, <var>cacheGroup</var>, <var>propertyName</var> )</a></li><li><span class="item-toggle-none"></span><a href="#sec-get-iterator-cached" title="GetIteratorCached ( subject, cacheGroup )"><span class="secnum">30.3.7</span> GetIteratorCached ( <var>subject</var>, <var>cacheGroup</var> )</a></li><li><span class="item-toggle-none"></span><a href="#sec-iterator-step-cached" title="IteratorStepCached ( iterator, cacheGroup )"><span class="secnum">30.3.8</span> IteratorStepCached ( <var>iterator</var>, <var>cacheGroup</var> )</a></li><li><span class="item-toggle-none"></span><a href="#sec-get-iterator-nth-value-cached" title="GetIteratorNthValueCached ( iterator, cacheGroup, n )"><span class="secnum">30.3.9</span> GetIteratorNthValueCached ( <var>iterator</var>, <var>cacheGroup</var>, <var>n</var> )</a></li><li><span class="item-toggle-none"></span><a href="#sec-finish-list-match" title="FinishListMatch ( iterator, cacheGroup, expectedLength )"><span class="secnum">30.3.10</span> FinishListMatch ( <var>iterator</var>, <var>cacheGroup</var>, <var>expectedLength</var> )</a></li><li><span class="item-toggle-none"></span><a href="#sec-finish-match" title="FinishMatch ( matchCompletion, cacheGroup )"><span class="secnum">30.3.11</span> FinishMatch ( <var>matchCompletion</var>, <var>cacheGroup</var> )</a></li></ol></li></ol></li><li><span class="item-toggle">+</span><a href="#sec-grammar-summary" title="Grammar Summary"><span class="secnum">A</span> Grammar Summary</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-expressions" title="Expressions"><span class="secnum">A.1</span> Expressions</a></li><li><span class="item-toggle-none"></span><a href="#sec-annex-match-patterns" title="Patterns"><span class="secnum">A.9</span> Patterns</a></li></ol></li><li><span class="item-toggle-none"></span><a href="#sec-copyright-and-software-license" title="Copyright & Software License"><span class="secnum">B</span> Copyright & Software License</a></li></ol></div></div><div id="spec-container"><h1 class="version">Stage 1 Draft / September 7, 2024</h1><h1 class="title">Pattern Matching</h1>
<style>
#welcome .secnum, [title="Welcome"] .secnum {
display: none;
}
emu-note[code] > .note, #welcome > h1 {
font-size: 0;
}
emu-note[code] > .note::before {
content: "Example";
font-size: 18px;
}
emu-note[code] pre {
margin: 0;
}
pre.inline {
display: inline;
}
pre.inline code {
display: inline;
font-style: italic;
text-decoration: underline;
}
body.folded .fold, body.folded .todo {
display: none;
}
.show-ao-annotations a.e-user-code::before, .show-ao-annotations span.e-user-code::before {
display: inline-block;
}
#sec-todos {
border-left: 5px solid #ff6600;
padding: 0.5em;
background: #ffeedd;
}
emu-intro {
margin-top: 1em !important;
}
[role="button"] {
cursor: pointer;
}
</style>
<emu-intro id="welcome">
<h1>Welcome</h1>
<emu-intro id="sec-todos">
<h1 class="attributes-tag">TODOs</h1>
<ul>
<li>
Scope and bindings
<ul>
<li>Basic case.</li>
<li>Work with <code>for</code> loop (<emu-xref aoid="CreatePerIterationEnvironment"><a href="https://tc39.es/ecma262/#sec-createperiterationenvironment">CreatePerIterationEnvironment</a></emu-xref>).</li>
<li>Work with function parameters.</li>
</ul>
</li>
</ul>
</emu-intro>
<emu-intro id="sec-nav">
<h1>Introduction</h1>
<p>This specification consists of the following parts:</p>
<ul>
<li><emu-xref href="#sec-pattern-matching" id="_ref_0"><a href="#sec-pattern-matching">Patterns in pattern matching</a></emu-xref></li>
<li>Interesting AOs:
<ul>
<li><emu-xref href="#sec-invoke-custom-matcher" title="" id="_ref_1"><a href="#sec-invoke-custom-matcher">InvokeCustomMatcher ( <var>matcher</var>, <var>subject</var>, <var>cacheGroup</var>, <var>kind</var>, <var>receiver</var> )</a></emu-xref></li>
<li><emu-xref href="#sec-pattern-match-cache-note" id="_ref_2"><a href="#sec-pattern-match-cache-note">Cache semantics</a></emu-xref></li>
</ul>
</li>
<li><emu-xref href="#sec-relational-operators" title="" id="_ref_3"><a href="#sec-relational-operators">The <code>is</code> expression</a></emu-xref></li>
<li><emu-xref href="#sec-match-expression" title="" id="_ref_4"><a href="#sec-match-expression">The <code>match</code> Expression</a></emu-xref></li>
<li>
Non-trivial Built-in <emu-xref href="#sec-well-known-symbols" id="_ref_19"><a href="#sec-well-known-symbols">%Symbol.customMatcher%</a></emu-xref> methods:
<ul>
<li><emu-xref href="#sec-function.prototype-%symbol.custommatcher%" title="" id="_ref_5"><a href="#sec-function.prototype-%symbol.custommatcher%">Function.prototype [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var>, <var>receiver</var> )</a></emu-xref></li>
<li><emu-xref href="#sec-regexp.prototype-%symbol.custommatcher%" title="" id="_ref_6"><a href="#sec-regexp.prototype-%symbol.custommatcher%">RegExp.prototype [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</a></emu-xref></li>
</ul>
</li>
<li>(TODO) Scope analysis changes: <emu-xref href="#sec-syntax-directed-operations" title="" id="_ref_7"><a href="#sec-syntax-directed-operations">Syntax-Directed Operations</a></emu-xref></li>
<li><code>new</code> semantics changes:
<emu-xref href="#sec-initializeinstance" id="_ref_8"><a href="#sec-initializeinstance">7.3.34</a></emu-xref>,
<emu-xref href="#sec-weakly-hold-targets-processing-model" id="_ref_9"><a href="#sec-weakly-hold-targets-processing-model">9.10</a></emu-xref>, and
<emu-xref href="#sec-runtime-semantics-classdefinitionevaluation" id="_ref_10"><a href="#sec-runtime-semantics-classdefinitionevaluation">15.7.14</a></emu-xref>
</li>
<li>
Possible extensions:
<emu-xref href="#sec-for-in-and-for-of-statements" title="" id="_ref_11"><a href="#sec-for-in-and-for-of-statements">The <code>for</code>-<code>in</code>, <code>for</code>-<code>of</code>, and <code>for</code>-<code>await</code>-<code>of</code> Statements</a></emu-xref> and
<emu-xref href="#sec-try-statement" title="" id="_ref_12"><a href="#sec-try-statement">The <code>try</code> Statement</a></emu-xref>
</li>
</ul>
<p>
Trivia built-in matchers are folded.
<a role="button" id="expand">Click to <span class="fold">not</span> show the trivia sections.</a>
</p>
<script defer="" async="" src="./assets/expand.js"></script>
</emu-intro>
<emu-intro id="sec-notes-layering">
<h1>Layering</h1>
<p>The pattern-matching champion group designed this proposal with a layering approach. It does not mean the proposal is an MVP. The champion group wishes to ship the proposal as a whole when possible, but we can drop some features if there is strong pushback from the committee.</p>
<p>This approach allows the champion group to consider how all features combine and also how the proposal should behave if any of the features are missing.</p>
<p>A feature will have a note if</p>
<ul>
<li>it is a convenient feature instead of a necessary feature.</li>
<li>not all champion group members represent the hope to include it.</li>
</ul>
</emu-intro>
</emu-intro>
<emu-clause class="fold" id="sec-overview" number="4">
<h1><span class="secnum">4</span> Overview</h1>
<emu-clause id="sec-organization-of-this-specification" number="5">
<h1><span class="secnum">4.5</span> Organization of This Specification</h1>
<p><ins>Clause <emu-xref href="#sec-pattern-matching" id="_ref_13"><a href="#sec-pattern-matching">30</a></emu-xref> describes the pattern-matching feature.</ins></p>
</emu-clause>
</emu-clause>
<emu-clause class="fold" id="sec-ecmascript-data-types-and-values" aoid="Type" number="6">
<h1><span class="secnum">6</span> ECMAScript Data Types and Values</h1>
<emu-clause id="sec-ecmascript-language-types">
<h1><span class="secnum">6.1</span> ECMAScript Language Types</h1>
<emu-clause id="sec-ecmascript-language-types-symbol-type" number="5">
<h1><span class="secnum">6.1.5</span> The Symbol Type</h1>
<emu-clause id="sec-well-known-symbols">
<h1><span class="secnum">6.1.5.1</span> Well-Known Symbols</h1>
<emu-table id="table-1" caption="Well-known Symbols"><figure><figcaption>Table 1: Well-known Symbols</figcaption>
<table>
<tbody>
<tr>
<th>
Specification Name
</th>
<th>
<var class="field">[[Description]]</var>
</th>
<th>
Value and Purpose
</th>
</tr>
<tr>
<td>
<ins><dfn tabindex="-1">%Symbol.customMatcher%</dfn></ins>
</td>
<td>
<ins><code>"Symbol.customMatcher"</code></ins>
</td>
<td>
<ins>A method that performs custom pattern matching semantics. Called by the semantics of the pattern-matching features.</ins>
</td>
</tr>
</tbody>
</table>
</figure></emu-table>
</emu-clause>
</emu-clause>
<emu-clause id="sec-object-internal-methods-and-internal-slots" number="7">
<h1><span class="secnum">6.1.7</span> Object Internal Methods and Internal Slots</h1>
<p><ins>All objects have an internal slot named <var class="field">[[ConstructedBy]]</var>, which is a <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type">List</a></emu-xref> of <emu-xref href="#sec-ecmascript-language-types" id="_ref_20"><a href="#sec-ecmascript-language-types">ECMAScript language values</a></emu-xref>.
This <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type">List</a></emu-xref> represents the origin of the object. Initially, it is an empty <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type">List</a></emu-xref>.</ins></p>
</emu-clause>
</emu-clause>
</emu-clause>
<emu-clause id="sec-abstract-operations" number="7">
<h1><span class="secnum">7</span> Abstract Operations</h1>
<emu-clause id="sec-operations-on-objects" number="3">
<h1><span class="secnum">7.3</span> Operations on Objects</h1>
<emu-clause oldids="sec-initializeinstanceelements" id="sec-initializeinstance" type="abstract operation" number="34" aoid="InitializeInstanceElements"><span id="sec-initializeinstanceelements"></span>
<h1><span class="secnum">7.3.34</span> InitializeInstanceElements ( <var>O</var>, <var>constructor</var> )</h1>
<p>The abstract operation InitializeInstanceElements takes arguments <var>O</var> (an Object) and <var>constructor</var> (an ECMAScript <emu-xref href="#function-object"><a href="https://tc39.es/ecma262/#function-object">function object</a></emu-xref>) and returns either a <emu-xref href="#sec-completion-record-specification-type"><a href="https://tc39.es/ecma262/#sec-completion-record-specification-type">normal completion containing</a></emu-xref> <emu-const>unused</emu-const> or a <emu-xref href="#sec-completion-record-specification-type"><a href="https://tc39.es/ecma262/#sec-completion-record-specification-type">throw completion</a></emu-xref>. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>methods</var> be the value of <var>constructor</var>.<var class="field">[[PrivateMethods]]</var>.</li><li>For each <emu-xref href="#sec-privateelement-specification-type"><a href="https://tc39.es/ecma262/#sec-privateelement-specification-type">PrivateElement</a></emu-xref> <var>method</var> of <var>methods</var>, do<ol><li>Perform ? <emu-xref aoid="PrivateMethodOrAccessorAdd"><a href="https://tc39.es/ecma262/#sec-privatemethodoraccessoradd">PrivateMethodOrAccessorAdd</a></emu-xref>(<var>O</var>, <var>method</var>).</li></ol></li><li>Let <var>fields</var> be the value of <var>constructor</var>.<var class="field">[[Fields]]</var>.</li><li>For each element <var>fieldRecord</var> of <var>fields</var>, do<ol><li>Perform ? <emu-xref aoid="DefineField"><a href="https://tc39.es/ecma262/#sec-definefield" class="e-user-code">DefineField</a></emu-xref>(<var>O</var>, <var>fieldRecord</var>).</li></ol></li><li><ins>Append <var>constructor</var> to <var>O</var>.<var class="field">[[ConstructedBy]]</var>.</ins></li><li>Return <emu-const>unused</emu-const>.</li></ol></emu-alg>
<emu-note type="editor"><span class="note">Editor's Note</span><div class="note-contents">Rename this abstract operation to <dfn tabindex="-1">InitializeInstance</dfn>.</div></emu-note>
</emu-clause>
</emu-clause>
</emu-clause>
<emu-clause class="todo" id="sec-syntax-directed-operations">
<h1><span class="secnum">8</span> Syntax-Directed Operations</h1>
<emu-clause id="sec-syntax-directed-operations-scope-analysis" number="2">
<h1><span class="secnum">8.2</span> Scope Analysis</h1>
<emu-clause id="sec-static-semantics-boundnames" type="sdo" number="1" aoid="BoundNames">
<h1><span class="secnum">8.2.1</span> Static Semantics: BoundNames</h1>
<p>The <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations"><a href="https://tc39.es/ecma262/#sec-algorithm-conventions-syntax-directed-operations">syntax-directed operation</a></emu-xref> BoundNames takes no arguments and returns a <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type">List</a></emu-xref> of Strings.</p>
<emu-note type="editor"><span class="note">Editor's Note</span><div class="note-contents">
TODO: Scope Analysis.
</div></emu-note>
</emu-clause>
<emu-clause id="sec-static-semantics-declarationpart" type="sdo" number="2" aoid="DeclarationPart">
<h1><span class="secnum">8.2.2</span> Static Semantics: DeclarationPart</h1>
<p>The <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations"><a href="https://tc39.es/ecma262/#sec-algorithm-conventions-syntax-directed-operations">syntax-directed operation</a></emu-xref> DeclarationPart takes no arguments and returns a <emu-xref href="#sec-syntactic-grammar"><a href="https://tc39.es/ecma262/#sec-syntactic-grammar">Parse Node</a></emu-xref>.</p>
<emu-note type="editor"><span class="note">Editor's Note</span><div class="note-contents">
TODO: Scope Analysis.
</div></emu-note>
</emu-clause>
<emu-clause id="sec-static-semantics-isconstantdeclaration" type="sdo" number="3" aoid="IsConstantDeclaration">
<h1><span class="secnum">8.2.3</span> Static Semantics: IsConstantDeclaration</h1>
<p>The <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations"><a href="https://tc39.es/ecma262/#sec-algorithm-conventions-syntax-directed-operations">syntax-directed operation</a></emu-xref> IsConstantDeclaration takes no arguments and returns a Boolean.</p>
<emu-note type="editor"><span class="note">Editor's Note</span><div class="note-contents">
TODO: Scope Analysis.
</div></emu-note>
</emu-clause>
<emu-clause id="sec-static-semantics-lexicallydeclarednames" type="sdo" number="4" aoid="LexicallyDeclaredNames">
<h1><span class="secnum">8.2.4</span> Static Semantics: LexicallyDeclaredNames</h1>
<p>The <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations"><a href="https://tc39.es/ecma262/#sec-algorithm-conventions-syntax-directed-operations">syntax-directed operation</a></emu-xref> LexicallyDeclaredNames takes no arguments and returns a <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type">List</a></emu-xref> of Strings.</p>
<emu-note type="editor"><span class="note">Editor's Note</span><div class="note-contents">
TODO: Scope Analysis.
</div></emu-note>
</emu-clause>
<emu-clause id="sec-static-semantics-lexicallyscopeddeclarations" type="sdo" number="5" aoid="LexicallyScopedDeclarations">
<h1><span class="secnum">8.2.5</span> Static Semantics: LexicallyScopedDeclarations</h1>
<p>The <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations"><a href="https://tc39.es/ecma262/#sec-algorithm-conventions-syntax-directed-operations">syntax-directed operation</a></emu-xref> LexicallyScopedDeclarations takes no arguments and returns a <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type">List</a></emu-xref> of <emu-xref href="#sec-syntactic-grammar"><a href="https://tc39.es/ecma262/#sec-syntactic-grammar">Parse Nodes</a></emu-xref>.</p>
<emu-note type="editor"><span class="note">Editor's Note</span><div class="note-contents">
TODO: Scope Analysis.
</div></emu-note>
</emu-clause>
<emu-clause id="sec-static-semantics-vardeclarednames" type="sdo" number="6" aoid="VarDeclaredNames">
<h1><span class="secnum">8.2.6</span> Static Semantics: VarDeclaredNames</h1>
<p>The <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations"><a href="https://tc39.es/ecma262/#sec-algorithm-conventions-syntax-directed-operations">syntax-directed operation</a></emu-xref> VarDeclaredNames takes no arguments and returns a <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type">List</a></emu-xref> of Strings.</p>
<emu-note type="editor"><span class="note">Editor's Note</span><div class="note-contents">
TODO: Scope Analysis.
</div></emu-note>
</emu-clause>
<emu-clause id="sec-static-semantics-varscopeddeclarations" type="sdo" number="7" aoid="VarScopedDeclarations">
<h1><span class="secnum">8.2.7</span> Static Semantics: VarScopedDeclarations</h1>
<p>The <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations"><a href="https://tc39.es/ecma262/#sec-algorithm-conventions-syntax-directed-operations">syntax-directed operation</a></emu-xref> VarScopedDeclarations takes no arguments and returns a <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type">List</a></emu-xref> of <emu-xref href="#sec-syntactic-grammar"><a href="https://tc39.es/ecma262/#sec-syntactic-grammar">Parse Nodes</a></emu-xref>.</p>
<emu-note type="editor"><span class="note">Editor's Note</span><div class="note-contents">
TODO: Scope Analysis.
</div></emu-note>
</emu-clause>
<emu-clause id="sec-static-semantics-toplevellexicallydeclarednames" type="sdo" number="8" aoid="TopLevelLexicallyDeclaredNames">
<h1><span class="secnum">8.2.8</span> Static Semantics: TopLevelLexicallyDeclaredNames</h1>
<p>The <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations"><a href="https://tc39.es/ecma262/#sec-algorithm-conventions-syntax-directed-operations">syntax-directed operation</a></emu-xref> TopLevelLexicallyDeclaredNames takes no arguments and returns a <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type">List</a></emu-xref> of Strings.</p>
<emu-note type="editor"><span class="note">Editor's Note</span><div class="note-contents">
TODO: Scope Analysis.
</div></emu-note>
</emu-clause>
<emu-clause id="sec-static-semantics-toplevellexicallyscopeddeclarations" type="sdo" number="9" aoid="TopLevelLexicallyScopedDeclarations">
<h1><span class="secnum">8.2.9</span> Static Semantics: TopLevelLexicallyScopedDeclarations</h1>
<p>The <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations"><a href="https://tc39.es/ecma262/#sec-algorithm-conventions-syntax-directed-operations">syntax-directed operation</a></emu-xref> TopLevelLexicallyScopedDeclarations takes no arguments and returns a <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type">List</a></emu-xref> of <emu-xref href="#sec-syntactic-grammar"><a href="https://tc39.es/ecma262/#sec-syntactic-grammar">Parse Nodes</a></emu-xref>.</p>
<emu-note type="editor"><span class="note">Editor's Note</span><div class="note-contents">
TODO: Scope Analysis.
</div></emu-note>
</emu-clause>
<emu-clause id="sec-static-semantics-toplevelvardeclarednames" type="sdo" number="10" aoid="TopLevelVarDeclaredNames">
<h1><span class="secnum">8.2.10</span> Static Semantics: TopLevelVarDeclaredNames</h1>
<p>The <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations"><a href="https://tc39.es/ecma262/#sec-algorithm-conventions-syntax-directed-operations">syntax-directed operation</a></emu-xref> TopLevelVarDeclaredNames takes no arguments and returns a <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type">List</a></emu-xref> of Strings.</p>
<emu-note type="editor"><span class="note">Editor's Note</span><div class="note-contents">
TODO: Scope Analysis.
</div></emu-note>
</emu-clause>
<emu-clause id="sec-static-semantics-toplevelvarscopeddeclarations" type="sdo" number="11" aoid="TopLevelVarScopedDeclarations">
<h1><span class="secnum">8.2.11</span> Static Semantics: TopLevelVarScopedDeclarations</h1>
<p>The <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations"><a href="https://tc39.es/ecma262/#sec-algorithm-conventions-syntax-directed-operations">syntax-directed operation</a></emu-xref> TopLevelVarScopedDeclarations takes no arguments and returns a <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type">List</a></emu-xref> of <emu-xref href="#sec-syntactic-grammar"><a href="https://tc39.es/ecma262/#sec-syntactic-grammar">Parse Nodes</a></emu-xref>.</p>
<emu-note type="editor"><span class="note">Editor's Note</span><div class="note-contents">
TODO: Scope Analysis.
</div></emu-note>
</emu-clause>
</emu-clause>
<emu-clause id="sec-syntax-directed-operations-miscellaneous" number="6">
<h1><span class="secnum">8.6</span> Miscellaneous</h1>
<emu-clause id="sec-runtime-semantics-bindinginitialization" type="sdo" number="2" aoid="BindingInitialization">
<h1><span class="secnum">8.6.2</span> Runtime Semantics: BindingInitialization</h1>
<p>The <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations"><a href="https://tc39.es/ecma262/#sec-algorithm-conventions-syntax-directed-operations">syntax-directed operation</a></emu-xref> BindingInitialization takes arguments <var>value</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_21"><a href="#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and <var>environment</var> (an <emu-xref href="#sec-environment-records"><a href="https://tc39.es/ecma262/#sec-environment-records">Environment Record</a></emu-xref> or <emu-val>undefined</emu-val>) and returns either a <emu-xref href="#sec-completion-record-specification-type"><a href="https://tc39.es/ecma262/#sec-completion-record-specification-type">normal completion containing</a></emu-xref> <emu-const>unused</emu-const> or an <emu-xref href="#sec-completion-record-specification-type"><a href="https://tc39.es/ecma262/#sec-completion-record-specification-type">abrupt completion</a></emu-xref>.</p>
<emu-note type="editor"><span class="note">Editor's Note</span><div class="note-contents">
TODO: Scope Analysis.
</div></emu-note>
</emu-clause>
<emu-clause id="sec-runtime-semantics-iteratorbindinginitialization" type="sdo" number="3" aoid="IteratorBindingInitialization">
<h1><span class="secnum">8.6.3</span> Runtime Semantics: IteratorBindingInitialization</h1>
<p>The <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations"><a href="https://tc39.es/ecma262/#sec-algorithm-conventions-syntax-directed-operations">syntax-directed operation</a></emu-xref> IteratorBindingInitialization takes arguments <var>iteratorRecord</var> (an <emu-xref href="#sec-iterator-records"><a href="https://tc39.es/ecma262/#sec-iterator-records">Iterator Record</a></emu-xref>) and <var>environment</var> (an <emu-xref href="#sec-environment-records"><a href="https://tc39.es/ecma262/#sec-environment-records">Environment Record</a></emu-xref> or <emu-val>undefined</emu-val>) and returns either a <emu-xref href="#sec-completion-record-specification-type"><a href="https://tc39.es/ecma262/#sec-completion-record-specification-type">normal completion containing</a></emu-xref> <emu-const>unused</emu-const> or an <emu-xref href="#sec-completion-record-specification-type"><a href="https://tc39.es/ecma262/#sec-completion-record-specification-type">abrupt completion</a></emu-xref>.</p>
<emu-note type="editor"><span class="note">Editor's Note</span><div class="note-contents">
TODO: Scope Analysis.
</div></emu-note>
</emu-clause>
</emu-clause>
</emu-clause>
<emu-clause class="fold" id="sec-executable-code-and-execution-contexts" number="9">
<h1><span class="secnum">9</span> Executable Code and Execution Contexts</h1>
<emu-clause id="sec-weakly-hold-targets-processing-model" oldids="sec-weakref-processing-model" number="10"><span id="sec-weakref-processing-model"></span>
<h1><span class="secnum">9.10</span> Processing Model of <del>WeakRef and FinalizationRegistry</del><ins>weakly hold</ins> Targets</h1>
<emu-clause id="sec-weakly-hold-execution" oldids="sec-weakref-execution" number="3"><span id="sec-weakref-execution"></span>
<h1><span class="secnum">9.10.3</span> Execution</h1>
<p>At any time, if a set of objects and/or symbols <var>S</var> is not <emu-xref href="#sec-liveness"><a href="https://tc39.es/ecma262/#sec-liveness">live</a></emu-xref>, an ECMAScript implementation may perform the following steps atomically:</p>
<emu-alg><ol><li>For each element <var>value</var> of <var>S</var>, do<ol><li>For each <emu-xref href="#sec-weak-ref-constructor"><a href="https://tc39.es/ecma262/#sec-weak-ref-constructor">WeakRef</a></emu-xref> <var>ref</var> such that <var>ref</var>.<var class="field">[[WeakRefTarget]]</var> is <var>value</var>, do<ol><li>Set <var>ref</var>.<var class="field">[[WeakRefTarget]]</var> to <emu-const>empty</emu-const>.</li></ol></li><li>For each <emu-xref href="#sec-finalization-registry-constructor"><a href="https://tc39.es/ecma262/#sec-finalization-registry-constructor">FinalizationRegistry</a></emu-xref> <var>fg</var> such that <var>fg</var>.<var class="field">[[Cells]]</var> contains a <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type">Record</a></emu-xref> <var>cell</var> such that <var>cell</var>.<var class="field">[[WeakRefTarget]]</var> is <var>value</var>, do<ol><li>Set <var>cell</var>.<var class="field">[[WeakRefTarget]]</var> to <emu-const>empty</emu-const>.</li><li>Optionally, perform <emu-xref aoid="HostEnqueueFinalizationRegistryCleanupJob"><a href="https://tc39.es/ecma262/#sec-host-cleanup-finalization-registry" class="e-user-code">HostEnqueueFinalizationRegistryCleanupJob</a></emu-xref>(<var>fg</var>).</li></ol></li><li>For each WeakMap <var>map</var> such that <var>map</var>.<var class="field">[[WeakMapData]]</var> contains a <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type">Record</a></emu-xref> <var>r</var> such that <var>r</var>.<var class="field">[[Key]]</var> is <var>value</var>, do<ol><li>Set <var>r</var>.<var class="field">[[Key]]</var> to <emu-const>empty</emu-const>.</li><li>Set <var>r</var>.<var class="field">[[Value]]</var> to <emu-const>empty</emu-const>.</li></ol></li><li>For each WeakSet <var>set</var> such that <var>set</var>.<var class="field">[[WeakSetData]]</var> contains <var>value</var>, do<ol><li>Replace the element of <var>set</var>.<var class="field">[[WeakSetData]]</var> whose value is <var>value</var> with an element whose value is <emu-const>empty</emu-const>.</li></ol></li><li><ins>For each Object <var>o</var> such that <var>o</var>.<var class="field">[[ConstructedBy]]</var> contains <var>value</var>, do</ins><ol><li><ins>Remove <var>value</var> from <var>o</var>.<var class="field">[[ConstructedBy]]</var>.</ins></li></ol></li></ol></li></ol></emu-alg>
</emu-clause>
</emu-clause>
</emu-clause>
<emu-clause class="fold" id="sec-ecmascript-language-lexical-grammar" number="12">
<h1><span class="secnum">12</span> ECMAScript Language: Lexical Grammar</h1>
<emu-clause id="sec-automatic-semicolon-insertion" number="10">
<h1><span class="secnum">12.10</span> Automatic Semicolon Insertion</h1>
<emu-clause id="sec-rules-of-automatic-semicolon-insertion" number="1">
<h1><span class="secnum">12.10.1</span> Rules of Automatic Semicolon Insertion</h1>
<emu-note><span class="note">Note</span><div class="note-contents">
<p>The following are the additions of the restricted productions in the grammar:</p>
<emu-grammar><emu-production name="RelationalExpression" params="In, Yield, Await">
<emu-nt params="In, Yield, Await"><a href="#prod-RelationalExpression">RelationalExpression</a><emu-mods><emu-params>[In, Yield, Await]</emu-params></emu-mods></emu-nt> <emu-geq>:</emu-geq> <emu-rhs a="4sv6neua">
<emu-nt id="_ref_194"><a href="#prod-RelationalExpression">RelationalExpression</a></emu-nt>
<emu-gann>[no <emu-nt><a href="https://tc39.es/ecma262/#prod-LineTerminator">LineTerminator</a></emu-nt> here]</emu-gann>
<emu-t>is</emu-t>
<emu-nt id="_ref_195"><a href="#prod-MatchPattern">MatchPattern</a></emu-nt>
</emu-rhs>
</emu-production>
<emu-production name="MatchExpression" params="Yield, Await">
<emu-nt params="Yield, Await"><a href="#prod-MatchExpression">MatchExpression</a><emu-mods><emu-params>[Yield, Await]</emu-params></emu-mods></emu-nt> <emu-geq>:</emu-geq> <emu-rhs a="mvw1s1gm">
<emu-nt params="?Yield, ?Await"><a href="https://tc39.es/ecma262/#prod-CoverCallExpressionAndAsyncArrowHead">CoverCallExpressionAndAsyncArrowHead</a><emu-mods><emu-params>[?Yield, ?Await]</emu-params></emu-mods></emu-nt>
<emu-gann>[no <emu-nt><a href="https://tc39.es/ecma262/#prod-LineTerminator">LineTerminator</a></emu-nt> here]</emu-gann>
<emu-t>{</emu-t>
<emu-nt params="?Yield, ?Await" id="_ref_196"><a href="#prod-MatchExpressionClauses">MatchExpressionClauses</a><emu-mods><emu-params>[?Yield, ?Await]</emu-params></emu-mods></emu-nt>
<emu-t>;</emu-t>
<emu-t>}</emu-t>
</emu-rhs>
</emu-production>
<emu-production name="MatchHead">
<emu-nt><a href="#prod-MatchHead">MatchHead</a></emu-nt> <emu-geq>:</emu-geq> <emu-rhs a="qvsbvt69">
<emu-t>match</emu-t>
<emu-gann>[no <emu-nt><a href="https://tc39.es/ecma262/#prod-LineTerminator">LineTerminator</a></emu-nt> here]</emu-gann>
<emu-t>(</emu-t>
<emu-nt><a href="https://tc39.es/ecma262/#prod-Expression">Expression</a></emu-nt>
<emu-t>)</emu-t>
</emu-rhs>
</emu-production>
</emu-grammar>
</div></emu-note>
</emu-clause>
<emu-clause id="sec-interesting-cases-of-automatic-semicolon-insertion" number="3">
<h1><span class="secnum">12.10.3</span> Interesting Cases of Automatic Semicolon Insertion</h1>
<emu-clause id="sec-asi-cases-with-no-lineterminator-here" number="2">
<h1><span class="secnum">12.10.3.2</span> Cases of Automatic Semicolon Insertion and “[no <emu-nt><a href="https://tc39.es/ecma262/#prod-LineTerminator">LineTerminator</a></emu-nt> here]”</h1>
<emu-clause id="sec-no-lineterminator-here-automatic-semicolon-insertion-list" number="1">
<h1><span class="secnum">12.10.3.2.1</span> List of Grammar Productions with Optional Operands and “[no <emu-nt><a href="https://tc39.es/ecma262/#prod-LineTerminator">LineTerminator</a></emu-nt> here]”</h1>
<ul>
<li><ins><emu-nt id="_ref_197"><a href="#prod-MatchExpression">MatchExpression</a></emu-nt>.</ins></li>
</ul>
</emu-clause>
</emu-clause>
</emu-clause>
</emu-clause>
</emu-clause>
<emu-clause id="sec-ecmascript-language-expressions" number="13">
<h1><span class="secnum">13</span> ECMAScript Language: Expressions</h1>
<emu-clause id="sec-primary-expression" number="2">
<h1><span class="secnum">13.2</span> Primary Expression</h1>
<h2>Syntax</h2>
<emu-grammar type="definition"><emu-production name="PrimaryExpression" params="Yield, Await" id="prod-PrimaryExpression">
<emu-nt params="Yield, Await"><a href="#prod-PrimaryExpression">PrimaryExpression</a><emu-mods><emu-params>[Yield, Await]</emu-params></emu-mods></emu-nt> <emu-geq>:</emu-geq> <emu-rhs a="mbzy6lvr">
<emu-nt><a href="https://tc39.es/ecma262/#prod-RegularExpressionLiteral">RegularExpressionLiteral</a></emu-nt>
</emu-rhs>
<ins><emu-rhs a="xhniddxr" id="prod-XSmG8KFu">
<emu-nt params="?Yield, ?Await" id="_ref_198"><a href="#prod-MatchExpression">MatchExpression</a><emu-mods><emu-params>[?Yield, ?Await]</emu-params></emu-mods></emu-nt>
</emu-rhs></ins>
</emu-production>
</emu-grammar>
<emu-clause id="sec-primary-expression-match-expression" number="10">
<h1><span class="secnum">13.2.10</span> Match Expression</h1>
<p>See <emu-xref href="#sec-match-expression" title="" id="_ref_14"><a href="#sec-match-expression">The <code>match</code> Expression</a></emu-xref> for <emu-grammar><emu-production name="PrimaryExpression" collapsed="" class=" inline">
<emu-nt><a href="#prod-PrimaryExpression">PrimaryExpression</a></emu-nt> <emu-geq>:</emu-geq> <emu-rhs a="hbnv2khd"><emu-nt id="_ref_199"><a href="#prod-MatchExpression">MatchExpression</a></emu-nt></emu-rhs>
</emu-production>
</emu-grammar></p>
</emu-clause>
</emu-clause>
<emu-clause id="sec-relational-operators" number="10">
<h1><span class="secnum">13.10</span> Relational Operators</h1>
<h2>Syntax</h2>
<emu-grammar type="definition"><emu-production name="RelationalExpression" params="In, Yield, Await" id="prod-RelationalExpression">
<emu-nt params="In, Yield, Await"><a href="#prod-RelationalExpression">RelationalExpression</a><emu-mods><emu-params>[In, Yield, Await]</emu-params></emu-mods></emu-nt> <emu-geq>:</emu-geq> <ins><emu-rhs a="7pwutwad" id="prod-EdmoEhta">
<emu-nt params="?In, ?Yield, ?Await" id="_ref_200"><a href="#prod-RelationalExpression">RelationalExpression</a><emu-mods><emu-params>[?In, ?Yield, ?Await]</emu-params></emu-mods></emu-nt>
<emu-gann>[no <emu-nt><a href="https://tc39.es/ecma262/#prod-LineTerminator">LineTerminator</a></emu-nt> here]</emu-gann>
<emu-t>is</emu-t>
<emu-nt params="?Yield, ?Await" id="_ref_201"><a href="#prod-MatchPattern">MatchPattern</a><emu-mods><emu-params>[?Yield, ?Await]</emu-params></emu-mods></emu-nt>
</emu-rhs></ins>
</emu-production>
</emu-grammar>
<emu-note code=""><span class="note">Note</span><div class="note-contents">
<pre><code class="javascript hljs"><span class="hljs-keyword">const</span> isOk = response is { <span class="hljs-attr">ok</span>: <span class="hljs-literal">true</span>, <span class="hljs-attr">status</span>: > <span class="hljs-number">200</span> and < <span class="hljs-number">400</span> };</code></pre>
</div></emu-note>
<emu-note type="editor"><span class="note">Editor's Note</span><div class="note-contents">
This feature can be replaced by <emu-xref href="#sec-match-expression" title="" id="_ref_15"><a href="#sec-match-expression">The <code>match</code> Expression</a></emu-xref>.
The code example above can be written as:
<pre><code class="javascript hljs"><span class="hljs-keyword">const</span> isOk = match (response) {
{ <span class="hljs-attr">ok</span>: <span class="hljs-literal">true</span>, <span class="hljs-attr">status</span>: > <span class="hljs-number">200</span> and < <span class="hljs-number">400</span> }: <span class="hljs-literal">true</span>,
<span class="hljs-attr">default</span>: <span class="hljs-literal">false</span>
};</code></pre>
</div></emu-note>
<emu-note type="editor"><span class="note">Editor's Note</span><div class="note-contents">
We may need to use a non-<emu-xref href="#sec-keywords-and-reserved-words"><a href="https://tc39.es/ecma262/#sec-keywords-and-reserved-words">contextual keyword</a></emu-xref> like <code>~=</code> instead of a <emu-xref href="#sec-keywords-and-reserved-words"><a href="https://tc39.es/ecma262/#sec-keywords-and-reserved-words">contextual keyword</a></emu-xref> like <code>is</code>. See <a href="https://github.com/waldemarhorwat/syntax/blob/main/contextual-keywords.md?rgh-link-date=2024-09-06T16%3A43%3A25Z" data-print-href="">waldemarhorwat/syntax@main/contextual-keywords.md</a>
and <a href="https://github.com/tc39/proposal-pattern-matching/issues/323" data-print-href="">Syntax effects on rest of the language</a>.
</div></emu-note>
<emu-clause id="sec-relational-operators-runtime-semantics-evaluation" number="1">
<h1><span class="secnum">13.10.1</span> Runtime Semantics: Evaluation</h1>
<emu-grammar><ins><emu-production name="RelationalExpression" collapsed="">
<emu-nt><a href="#prod-RelationalExpression">RelationalExpression</a></emu-nt> <emu-geq>:</emu-geq> <emu-rhs a="uyg6vvvy">
<emu-nt id="_ref_202"><a href="#prod-RelationalExpression">RelationalExpression</a></emu-nt>
<emu-t>is</emu-t>
<emu-nt id="_ref_203"><a href="#prod-MatchPattern">MatchPattern</a></emu-nt>
</emu-rhs>
</emu-production></ins>
</emu-grammar>
<emu-alg><ol><li>Let <var>lref</var> be ? <emu-xref aoid="Evaluation"><a href="https://tc39.es/ecma262/#sec-evaluation" class="e-user-code">Evaluation</a></emu-xref> of <emu-nt id="_ref_204"><a href="#prod-RelationalExpression">RelationalExpression</a></emu-nt>.</li><li>Let <var>lval</var> be ? <emu-xref aoid="GetValue"><a href="https://tc39.es/ecma262/#sec-getvalue" class="e-user-code">GetValue</a></emu-xref>(<var>lref</var>).</li><li>Let <var>cacheGroup</var> be <emu-xref aoid="CreateMatchCache" id="_ref_22"><a href="#sec-creatematchcache">CreateMatchCache</a></emu-xref>().</li><li>Let <var>matchCompletion</var> be ? <emu-xref aoid="MatchPatternMatches" id="_ref_23"><a href="#sec-match-pattern-matches" class="e-user-code">MatchPatternMatches</a></emu-xref> of <emu-nt id="_ref_205"><a href="#prod-MatchPattern">MatchPattern</a></emu-nt> with argument <var>lval</var> and <var>cacheGroup</var>.</li><li>If <var>matchCompletion</var> is a <emu-xref href="#sec-completion-record-specification-type"><a href="https://tc39.es/ecma262/#sec-completion-record-specification-type">normal completion</a></emu-xref>, then<ol><li>If <var>matchCompletion</var>.<var class="field">[[Value]]</var> is <emu-const>not-matched</emu-const>, set <var>matchCompletion</var> to <emu-xref aoid="NormalCompletion"><a href="https://tc39.es/ecma262/#sec-normalcompletion">NormalCompletion</a></emu-xref>(<emu-val>false</emu-val>).</li><li>Else, set <var>matchCompletion</var> to <emu-xref aoid="NormalCompletion"><a href="https://tc39.es/ecma262/#sec-normalcompletion">NormalCompletion</a></emu-xref>(<emu-val>true</emu-val>).</li></ol></li><li>Let <var>result</var> be <emu-xref aoid="Completion"><a href="https://tc39.es/ecma262/#sec-completion-ao">Completion</a></emu-xref>(<emu-xref aoid="FinishMatch" id="_ref_24"><a href="#sec-finish-match" class="e-user-code">FinishMatch</a></emu-xref>(<var>matchCompletion</var>, <var>cacheGroup</var>)).</li><li><emu-xref href="#assert"><a href="https://tc39.es/ecma262/#assert">Assert</a></emu-xref>: <var>result</var> is a <emu-xref href="#sec-completion-record-specification-type"><a href="https://tc39.es/ecma262/#sec-completion-record-specification-type">normal completion</a></emu-xref> or an <emu-xref href="#sec-completion-record-specification-type"><a href="https://tc39.es/ecma262/#sec-completion-record-specification-type">abrupt completion</a></emu-xref>.</li><li>Return <var>result</var>.</li></ol></emu-alg>
</emu-clause>
</emu-clause>
</emu-clause>
<emu-clause id="sec-ecmascript-language-statements-and-declarations" number="14">
<h1><span class="secnum">14</span> ECMAScript Language: Statements and Declarations</h1>
<h2>Syntax</h2>
<emu-clause id="sec-iteration-statements" number="7">
<h1><span class="secnum">14.7</span> Iteration Statements</h1>
<emu-clause id="sec-for-in-and-for-of-statements">
<h1><span class="secnum">14.7.1</span> The <code>for</code>-<code>in</code>, <code>for</code>-<code>of</code>, and <code>for</code>-<code>await</code>-<code>of</code> Statements</h1>
<emu-note type="editor"><span class="note">Editor's Note</span><div class="note-contents">
It is possible to add pattern-matching to the <code>for</code> iteration statements. It might look like this:
<pre><code class="javascript hljs"><span class="hljs-keyword">for</span> (<span class="hljs-keyword">const</span> response <span class="hljs-keyword">of</span> responses) {
<span class="hljs-keyword">if</span> (item is { <span class="hljs-attr">ok</span>: <span class="hljs-literal">true</span>, <span class="hljs-keyword">let</span> body }) {
}
}
<span class="hljs-comment">// can be written as</span>
<span class="hljs-keyword">for</span> (<span class="hljs-keyword">const</span> response is { <span class="hljs-attr">ok</span>: <span class="hljs-literal">true</span>, <span class="hljs-keyword">let</span> body } <span class="hljs-keyword">of</span> responses) {
}
<span class="hljs-comment">// or</span>
<span class="hljs-keyword">for</span> (<span class="hljs-keyword">const</span> response <span class="hljs-keyword">of</span> responses matches { <span class="hljs-attr">ok</span>: <span class="hljs-literal">true</span>, <span class="hljs-keyword">let</span> body }) {
}</code></pre>
</div></emu-note>
</emu-clause>
</emu-clause>
<emu-clause id="sec-try-statement" number="14">
<h1><span class="secnum">14.14</span> The <code>try</code> Statement</h1>
<emu-note type="editor"><span class="note">Editor's Note</span><div class="note-contents">
It is possible to add pattern-matching to the <code>try</code> statement. It might look like this:
<pre><code class="javascript hljs"><span class="hljs-keyword">try</span> { }
<span class="hljs-keyword">catch</span> (error) {
<span class="hljs-keyword">if</span> (error is { <span class="hljs-attr">message</span>: <span class="hljs-regexp">/JSON/</span> }) { <span class="hljs-keyword">return</span> <span class="hljs-literal">null</span>; }
<span class="hljs-keyword">throw</span> error;
}
<span class="hljs-comment">// can be written as</span>
<span class="hljs-keyword">try</span> { }
<span class="hljs-keyword">catch</span> (error is { <span class="hljs-attr">message</span>: <span class="hljs-regexp">/JSON/</span> }) { <span class="hljs-keyword">return</span> <span class="hljs-literal">null</span>; }
<span class="hljs-comment">// unmatched error will be re-thrown.</span></code></pre>
</div></emu-note>
</emu-clause>
</emu-clause>
<emu-clause id="sec-ecmascript-language-functions-and-classes" number="15">
<h1><span class="secnum">15</span> ECMAScript Language: Functions and Classes</h1>
<emu-clause id="sec-class-definitions" number="7">
<h1><span class="secnum">15.7</span> Class Definitions</h1>
<emu-clause id="sec-runtime-semantics-classdefinitionevaluation" type="sdo" number="14" aoid="ClassDefinitionEvaluation">
<h1><span class="secnum">15.7.14</span> Runtime Semantics: ClassDefinitionEvaluation</h1>
<p>The <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations"><a href="https://tc39.es/ecma262/#sec-algorithm-conventions-syntax-directed-operations">syntax-directed operation</a></emu-xref> ClassDefinitionEvaluation takes arguments <var>classBinding</var> (a String or <emu-val>undefined</emu-val>) and <var>className</var> (a <emu-xref href="#sec-object-type"><a href="https://tc39.es/ecma262/#sec-object-type">property key</a></emu-xref> or a <emu-xref href="#sec-private-names"><a href="https://tc39.es/ecma262/#sec-private-names">Private Name</a></emu-xref>) and returns either a <emu-xref href="#sec-completion-record-specification-type"><a href="https://tc39.es/ecma262/#sec-completion-record-specification-type">normal completion containing</a></emu-xref> a <emu-xref href="#function-object"><a href="https://tc39.es/ecma262/#function-object">function object</a></emu-xref> or an <emu-xref href="#sec-completion-record-specification-type"><a href="https://tc39.es/ecma262/#sec-completion-record-specification-type">abrupt completion</a></emu-xref>.</p>
<emu-note type="editor"><span class="note">Editor's Note</span><div class="note-contents">
See <a href="https://github.com/tc39/ecma262/pull/3212/files" target="_blank" data-print-href="">Editorial: call MakeClassConstructor on default class constructor</a>.
</div></emu-note>
</emu-clause>
</emu-clause>
<emu-clause class="fold" id="sec-tail-position-calls" number="10">
<h1><span class="secnum">15.10</span> Tail Position Calls</h1>
<emu-clause id="sec-static-semantics-hascallintailposition" number="2" type="sdo" aoid="HasCallInTailPosition">
<h1><span class="secnum">15.10.2</span> Static Semantics: HasCallInTailPosition</h1>
<p>The <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations"><a href="https://tc39.es/ecma262/#sec-algorithm-conventions-syntax-directed-operations">syntax-directed operation</a></emu-xref> HasCallInTailPosition takes argument <var>call</var> (a <emu-nt><a href="https://tc39.es/ecma262/#prod-CallExpression">CallExpression</a></emu-nt> <emu-xref href="#sec-syntactic-grammar"><a href="https://tc39.es/ecma262/#sec-syntactic-grammar">Parse Node</a></emu-xref>, a <emu-nt><a href="https://tc39.es/ecma262/#prod-MemberExpression">MemberExpression</a></emu-nt> <emu-xref href="#sec-syntactic-grammar"><a href="https://tc39.es/ecma262/#sec-syntactic-grammar">Parse Node</a></emu-xref>, or an <emu-nt><a href="https://tc39.es/ecma262/#prod-OptionalChain">OptionalChain</a></emu-nt> <emu-xref href="#sec-syntactic-grammar"><a href="https://tc39.es/ecma262/#sec-syntactic-grammar">Parse Node</a></emu-xref>) and returns a Boolean. It is defined piecewise over the following productions:</p>
<emu-grammar><ins><emu-production name="RelationalExpression" collapsed="">
<emu-nt><a href="#prod-RelationalExpression">RelationalExpression</a></emu-nt> <emu-geq>:</emu-geq> <emu-rhs a="uyg6vvvy" id="prod-9oXzuZL6">
<emu-nt id="_ref_206"><a href="#prod-RelationalExpression">RelationalExpression</a></emu-nt>
<emu-t>is</emu-t>
<emu-nt id="_ref_207"><a href="#prod-MatchPattern">MatchPattern</a></emu-nt>
</emu-rhs>
</emu-production></ins>
</emu-grammar>
<emu-alg><ol><li>Return <emu-val>false</emu-val>.</li></ol></emu-alg>
<emu-grammar><ins><emu-production name="PrimaryExpression" collapsed="">
<emu-nt><a href="#prod-PrimaryExpression">PrimaryExpression</a></emu-nt> <emu-geq>:</emu-geq> <emu-rhs a="hbnv2khd" id="prod-UB1LtDnR"><emu-nt id="_ref_208"><a href="#prod-MatchExpression">MatchExpression</a></emu-nt></emu-rhs>
</emu-production></ins>
</emu-grammar>
<emu-alg><ol><li>Return <emu-xref aoid="HasCallInTailPosition" id="_ref_25"><a href="#sec-static-semantics-hascallintailposition">HasCallInTailPosition</a></emu-xref> of <emu-nt id="_ref_209"><a href="#prod-MatchExpression">MatchExpression</a></emu-nt> with argument <var>call</var>.</li></ol></emu-alg>
<emu-grammar><ins><emu-production name="MatchExpression" collapsed="">
<emu-nt><a href="#prod-MatchExpression">MatchExpression</a></emu-nt> <emu-geq>:</emu-geq> <emu-rhs a="y2kk1jwh" id="prod-BHK6aZq8">
<emu-nt><a href="https://tc39.es/ecma262/#prod-CoverCallExpressionAndAsyncArrowHead">CoverCallExpressionAndAsyncArrowHead</a></emu-nt>
<emu-t>{</emu-t>
<emu-nt id="_ref_210"><a href="#prod-MatchExpressionClauses">MatchExpressionClauses</a></emu-nt>
<emu-t>;</emu-t>
<emu-t>}</emu-t>
</emu-rhs>
</emu-production></ins>
</emu-grammar>
<emu-alg><ol><li>Return <emu-xref aoid="HasCallInTailPosition" id="_ref_26"><a href="#sec-static-semantics-hascallintailposition">HasCallInTailPosition</a></emu-xref> of <emu-nt id="_ref_211"><a href="#prod-MatchExpressionClauses">MatchExpressionClauses</a></emu-nt> with argument <var>call</var>.</li></ol></emu-alg>
<emu-grammar><ins><emu-production name="MatchExpressionClauses" collapsed="">
<emu-nt><a href="#prod-MatchExpressionClauses">MatchExpressionClauses</a></emu-nt> <emu-geq>:</emu-geq> <emu-rhs a="uzg4qni-" id="prod-YG9CRILW"><emu-nt id="_ref_212"><a href="#prod-MatchExpressionClause">MatchExpressionClause</a></emu-nt></emu-rhs>
</emu-production></ins>
</emu-grammar>
<emu-alg><ol><li>Return <emu-xref aoid="HasCallInTailPosition" id="_ref_27"><a href="#sec-static-semantics-hascallintailposition">HasCallInTailPosition</a></emu-xref> of <emu-nt id="_ref_213"><a href="#prod-MatchExpressionClause">MatchExpressionClause</a></emu-nt> with argument <var>call</var>.</li></ol></emu-alg>
<emu-grammar><ins><emu-production name="MatchExpressionClauses" collapsed="">
<emu-nt><a href="#prod-MatchExpressionClauses">MatchExpressionClauses</a></emu-nt> <emu-geq>:</emu-geq> <emu-rhs a="mxhusj8b" id="prod-O1ji-jbG">
<emu-nt id="_ref_214"><a href="#prod-MatchExpressionClauses">MatchExpressionClauses</a></emu-nt>
<emu-t>;</emu-t>
<emu-nt id="_ref_215"><a href="#prod-MatchExpressionClause">MatchExpressionClause</a></emu-nt>
</emu-rhs>
</emu-production></ins>
</emu-grammar>
<emu-alg><ol><li>Let <var>result</var> be <emu-xref aoid="HasCallInTailPosition" id="_ref_28"><a href="#sec-static-semantics-hascallintailposition">HasCallInTailPosition</a></emu-xref> of <emu-nt id="_ref_216"><a href="#prod-MatchExpressionClauses">MatchExpressionClauses</a></emu-nt> with argument <var>call</var>.</li><li>If <var>result</var> is <emu-val>true</emu-val>, return <emu-val>true</emu-val>.</li><li>Return <emu-xref aoid="HasCallInTailPosition" id="_ref_29"><a href="#sec-static-semantics-hascallintailposition">HasCallInTailPosition</a></emu-xref> of <emu-nt id="_ref_217"><a href="#prod-MatchExpressionClause">MatchExpressionClause</a></emu-nt> with argument <var>call</var>.</li></ol></emu-alg>
<emu-grammar><ins><emu-production name="MatchExpressionClauses" collapsed="">
<emu-nt><a href="#prod-MatchExpressionClauses">MatchExpressionClauses</a></emu-nt> <emu-geq>:</emu-geq> <emu-rhs a="g1pmaudo" id="prod-ac1fz2Ib">
<emu-nt id="_ref_218"><a href="#prod-MatchExpressionClauses">MatchExpressionClauses</a></emu-nt>
<emu-t>;</emu-t>
<emu-t>default</emu-t>
<emu-t>:</emu-t>
<emu-nt><a href="https://tc39.es/ecma262/#prod-Expression">Expression</a></emu-nt>
</emu-rhs>
</emu-production></ins>
</emu-grammar>
<emu-alg><ol><li>Let <var>result</var> be <emu-xref aoid="HasCallInTailPosition" id="_ref_30"><a href="#sec-static-semantics-hascallintailposition">HasCallInTailPosition</a></emu-xref> of <emu-nt id="_ref_219"><a href="#prod-MatchExpressionClauses">MatchExpressionClauses</a></emu-nt> with argument <var>call</var>.</li><li>If <var>result</var> is <emu-val>true</emu-val>, return <emu-val>true</emu-val>.</li><li>Return <emu-xref aoid="HasCallInTailPosition" id="_ref_31"><a href="#sec-static-semantics-hascallintailposition">HasCallInTailPosition</a></emu-xref> of <emu-nt><a href="https://tc39.es/ecma262/#prod-Expression">Expression</a></emu-nt> with argument <var>call</var>.</li></ol></emu-alg>
<emu-grammar><ins><emu-production name="MatchExpressionClauses" collapsed="">
<emu-nt><a href="#prod-MatchExpressionClauses">MatchExpressionClauses</a></emu-nt> <emu-geq>:</emu-geq> <emu-rhs a="xhzralk2" id="prod-4UejTJZU">
<emu-t>default</emu-t>
<emu-t>:</emu-t>
<emu-nt><a href="https://tc39.es/ecma262/#prod-Expression">Expression</a></emu-nt>
</emu-rhs>
</emu-production></ins>
</emu-grammar>
<emu-alg><ol><li>Return <emu-xref aoid="HasCallInTailPosition" id="_ref_32"><a href="#sec-static-semantics-hascallintailposition">HasCallInTailPosition</a></emu-xref> of <emu-nt><a href="https://tc39.es/ecma262/#prod-Expression">Expression</a></emu-nt> with argument <var>call</var>.</li></ol></emu-alg>
<emu-grammar><ins><emu-production name="MatchExpressionClause" collapsed="">
<emu-nt><a href="#prod-MatchExpressionClause">MatchExpressionClause</a></emu-nt> <emu-geq>:</emu-geq> <emu-rhs a="pjnnj8-j" id="prod-FYuYdt05">
<emu-nt id="_ref_220"><a href="#prod-MatchPattern">MatchPattern</a></emu-nt>
<emu-t>:</emu-t>
<emu-nt><a href="https://tc39.es/ecma262/#prod-Expression">Expression</a></emu-nt>
</emu-rhs>
</emu-production></ins>
</emu-grammar>
<emu-alg><ol><li>Return <emu-xref aoid="HasCallInTailPosition" id="_ref_33"><a href="#sec-static-semantics-hascallintailposition">HasCallInTailPosition</a></emu-xref> of <emu-nt><a href="https://tc39.es/ecma262/#prod-Expression">Expression</a></emu-nt> with argument <var>call</var>.</li></ol></emu-alg>
</emu-clause>
</emu-clause>
</emu-clause>
<emu-clause id="sec-fundamental-objects" number="20">
<h1><span class="secnum">20</span> Fundamental Objects</h1>
<emu-clause class="fold" id="sec-object-objects" number="1">
<h1><span class="secnum">20.1</span> Object Objects</h1>
<emu-clause id="sec-properties-of-the-object-constructor" number="2">
<h1><span class="secnum">20.1.2</span> Properties of the Object Constructor</h1>
<emu-clause id="sec-object-%symbol.custommatcher%" number="24">
<h1><span class="secnum">20.1.2.24</span> Object [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</h1>
<p>This function performs the following steps when called:</p>
<emu-alg><ol><li>Perform ? <emu-xref aoid="ValidateCustomMatcherHint" id="_ref_34"><a href="#sec-validatecustommatcherhint">ValidateCustomMatcherHint</a></emu-xref>(<var>hint</var>, <emu-const>boolean</emu-const>).</li><li>If <var>subject</var> <emu-xref href="#sec-object-type"><a href="https://tc39.es/ecma262/#sec-object-type">is not an Object</a></emu-xref>, return <emu-val>false</emu-val>.</li><li>Return <emu-val>true</emu-val>.</li></ol></emu-alg>
</emu-clause>
</emu-clause>
</emu-clause>
<emu-clause id="sec-function-objects" number="2">
<h1><span class="secnum">20.2</span> Function Objects</h1>
<emu-clause id="sec-properties-of-the-function-constructor" number="2">
<h1><span class="secnum">20.2.2</span> Properties of the Function Constructor</h1>
<emu-clause id="sec-function-%symbol.custommatcher%" number="2">
<h1><span class="secnum">20.2.2.2</span> Function [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</h1>
<p>This function performs the following steps when called:</p>
<emu-alg><ol><li>Perform ? <emu-xref aoid="ValidateCustomMatcherHint" id="_ref_35"><a href="#sec-validatecustommatcherhint">ValidateCustomMatcherHint</a></emu-xref>(<var>hint</var>, <emu-const>boolean</emu-const>).</li><li>Return <emu-xref aoid="IsCallable"><a href="https://tc39.es/ecma262/#sec-iscallable">IsCallable</a></emu-xref>(<var>subject</var>).</li></ol></emu-alg>
</emu-clause>
</emu-clause>
<emu-clause id="sec-properties-of-the-function-prototype-object" number="3">
<h1><span class="secnum">20.2.3</span> Properties of the Function Prototype Object</h1>
<emu-clause id="sec-function.prototype-%symbol.custommatcher%" number="7">
<h1><span class="secnum">20.2.3.7</span> Function.prototype [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var>, <var>receiver</var> )</h1>
<p>This function performs the following steps when called:</p>
<emu-alg><ol><li>Perform ? <emu-xref aoid="ValidateCustomMatcherHint" id="_ref_36"><a href="#sec-validatecustommatcherhint">ValidateCustomMatcherHint</a></emu-xref>(<var>hint</var>).</li><li>Let <var>func</var> be the <emu-val>this</emu-val> value.</li><li>If <emu-xref aoid="IsCallable"><a href="https://tc39.es/ecma262/#sec-iscallable">IsCallable</a></emu-xref>(<var>func</var>) is false, throw a <emu-val>TypeError</emu-val> exception.</li><li>If <var>subject</var>.<var class="field">[[ConstructedBy]]</var> contains <var>func</var>, return <emu-val>true</emu-val>.</li><li>If <var>func</var> does not have a <var class="field">[[IsClassConstructor]]</var> internal slot or <var>func</var>.<var class="field">[[IsClassConstructor]]</var> is <emu-val>false</emu-val>, return ? <emu-xref aoid="Call"><a href="https://tc39.es/ecma262/#sec-call" class="e-user-code">Call</a></emu-xref>(<var>func</var>, <var>receiver</var>, « <var>subject</var>, <var>hint</var> »).</li><li>Return <emu-val>false</emu-val>.</li></ol></emu-alg>
<emu-note code=""><span class="note">Note</span><div class="note-contents"><pre><code class="javascript hljs"><span class="hljs-comment">// For non-class functions.</span>
[] is <span class="hljs-title class_">Array</span>.<span class="hljs-property">isArray</span>; <span class="hljs-comment">// true, by Array.isArray(expr)</span>
<span class="hljs-comment">// For objects created by `new`, it uses private-field-like semantics.</span>
<span class="hljs-keyword">class</span> <span class="hljs-title class_">MyError</span> <span class="hljs-keyword">extends</span> <span class="hljs-title class_ inherited__">Error</span> {}
<span class="hljs-keyword">const</span> myError = <span class="hljs-keyword">new</span> <span class="hljs-title class_">MyError</span>();
myError is <span class="hljs-title class_">MyError</span>; <span class="hljs-comment">// true</span>
myError is <span class="hljs-title class_">Error</span>; <span class="hljs-comment">// true</span>
<span class="hljs-title class_">Object</span>.<span class="hljs-title function_">create</span>(<span class="hljs-title class_">MyError</span>.<span class="hljs-property"><span class="hljs-keyword">prototype</span></span>) is <span class="hljs-title class_">MyError</span>; <span class="hljs-comment">// false</span>
<span class="hljs-comment">// Also works for normal functions</span>
<span class="hljs-keyword">function</span> <span class="hljs-title function_">ES5StyleClass</span>(<span class="hljs-params"></span>) {}
<span class="hljs-keyword">new</span> <span class="hljs-title function_">ES5StyleClass</span>() is ES5StyleClass; <span class="hljs-comment">// true</span>
<span class="hljs-title class_">Object</span>.<span class="hljs-title function_">create</span>(ES5StyleClass.<span class="hljs-property"><span class="hljs-keyword">prototype</span></span>) is ES5StyleClass; <span class="hljs-comment">// false</span></code></pre></div></emu-note>
<emu-note type="editor"><span class="note">Editor's Note</span><div class="note-contents">
<p>This does not work with ES5 style class inherit.</p>
<pre><code class="javascript hljs"><span class="hljs-keyword">function</span> <span class="hljs-title function_">MyError</span>(<span class="hljs-params"></span>) {
<span class="hljs-title class_">Error</span>.<span class="hljs-title function_">call</span>(<span class="hljs-variable language_">this</span>);
}
<span class="hljs-title class_">MyError</span>.<span class="hljs-property"><span class="hljs-keyword">prototype</span></span> = <span class="hljs-title class_">Object</span>.<span class="hljs-title function_">create</span>(<span class="hljs-title class_">Error</span>.<span class="hljs-property"><span class="hljs-keyword">prototype</span></span>);
<span class="hljs-keyword">var</span> error = <span class="hljs-keyword">new</span> <span class="hljs-title class_">MyError</span>();
error is <span class="hljs-title class_">MyError</span>; <span class="hljs-comment">// true</span>
error is <span class="hljs-title class_">Error</span>; <span class="hljs-comment">// false</span></code></pre>
</div></emu-note>
<emu-note type="editor"><span class="note">Editor's Note</span><div class="note-contents">
<p>Not everyone in the champion group agrees with private-field-like brand check semantics.</p>
<p>
There are
<a href="https://github.com/tc39/proposal-pattern-matching/pull/293#issuecomment-1725097699" target="_blank" data-print-href="">performance concerns</a>,
<a href="https://github.com/tc39/proposal-pattern-matching/pull/293#issuecomment-1725097699" target="_blank" data-print-href="">"hackable" concerns</a>, and
<a href="https://github.com/tc39/proposal-pattern-matching/pull/293#issuecomment-1725097699" target="_blank" data-print-href="">interaction
with %Symbol.hasInstance% concerns</a>.
</p>
<p>Another approach is to use the <code>instanceof</code> semantics.</p>
</div></emu-note>
</emu-clause>
</emu-clause>
</emu-clause>
<emu-clause class="fold" id="sec-boolean-objects" number="3">
<h1><span class="secnum">20.3</span> Boolean Objects</h1>
<emu-clause id="sec-properties-of-the-boolean-constructor" number="2">
<h1><span class="secnum">20.3.2</span> Properties of the Boolean Constructor</h1>
<emu-clause id="sec-boolean-%symbol.custommatcher%" number="2">
<h1><span class="secnum">20.3.2.2</span> Boolean [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</h1>
<p>This function performs the following steps when called:</p>
<emu-alg><ol><li>Perform ? <emu-xref aoid="ValidateCustomMatcherHint" id="_ref_37"><a href="#sec-validatecustommatcherhint">ValidateCustomMatcherHint</a></emu-xref>(<var>hint</var>).</li><li>If <var>subject</var> <emu-xref href="#sec-ecmascript-language-types-boolean-type"><a href="https://tc39.es/ecma262/#sec-ecmascript-language-types-boolean-type">is not a Boolean</a></emu-xref> and does not have a <var class="field">[[BooleanData]]</var> internal slot, return <emu-val>false</emu-val>.</li><li>If <var>hint</var> is <emu-val>"boolean"</emu-val>, return <emu-val>true</emu-val>.</li><li>If <var>subject</var> <emu-xref href="#sec-ecmascript-language-types-boolean-type"><a href="https://tc39.es/ecma262/#sec-ecmascript-language-types-boolean-type">is a Boolean</a></emu-xref>, return <emu-xref aoid="CreateArrayFromList"><a href="https://tc39.es/ecma262/#sec-createarrayfromlist">CreateArrayFromList</a></emu-xref>(« <var>subject</var> »).</li><li>Return <emu-xref aoid="CreateArrayFromList"><a href="https://tc39.es/ecma262/#sec-createarrayfromlist">CreateArrayFromList</a></emu-xref>(« <var>subject</var>.<var class="field">[[BooleanData]]</var> »).</li></ol></emu-alg>
</emu-clause>
</emu-clause>
<emu-note type="editor"><span class="note">Editor's Note</span><div class="note-contents">
Another approach is to ignore boxed primitives and only match primitive values.
</div></emu-note>
</emu-clause>
<emu-clause class="fold" id="sec-symbol-objects" number="4">
<h1><span class="secnum">20.4</span> Symbol Objects</h1>
<emu-clause id="sec-properties-of-the-symbol-constructor" number="2">
<h1><span class="secnum">20.4.2</span> Properties of the Symbol Constructor</h1>
<emu-clause id="sec-symbol.custommatcher" number="17">
<h1><span class="secnum">20.4.2.17</span> Symbol.customMatcher</h1>
<p>The initial value of <code>Symbol.customMatcher</code> is the well-known symbol <emu-xref href="#sec-well-known-symbols" id="_ref_38"><a href="#sec-well-known-symbols">%Symbol.customMatcher%</a></emu-xref> (<emu-xref href="#table-well-known-symbols"><a href="https://tc39.es/ecma262/#table-well-known-symbols">Table 1</a></emu-xref>).</p>
<p>This property has the attributes { <var class="field">[[Writable]]</var>: <emu-val>false</emu-val>, <var class="field">[[Enumerable]]</var>: <emu-val>false</emu-val>, <var class="field">[[Configurable]]</var>: <emu-val>false</emu-val> }.</p>
</emu-clause>
<emu-clause id="sec-symbol-%symbol.custommatcher%">
<h1><span class="secnum">20.4.2.18</span> Symbol [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</h1>
<p>This function performs the following steps when called:</p>
<emu-alg><ol><li>Perform ? <emu-xref aoid="ValidateCustomMatcherHint" id="_ref_39"><a href="#sec-validatecustommatcherhint">ValidateCustomMatcherHint</a></emu-xref>(<var>hint</var>).</li><li>If <var>subject</var> <emu-xref href="#sec-ecmascript-language-types-symbol-type" id="_ref_40"><a href="#sec-ecmascript-language-types-symbol-type">is not a Symbol</a></emu-xref> and does not have a <var class="field">[[SymbolData]]</var> internal slot, return <emu-val>false</emu-val>.</li><li>If <var>hint</var> is <emu-val>"boolean"</emu-val>, return <emu-val>true</emu-val>.</li><li>If <var>subject</var> <emu-xref href="#sec-ecmascript-language-types-symbol-type" id="_ref_41"><a href="#sec-ecmascript-language-types-symbol-type">is a Symbol</a></emu-xref>, return <emu-xref aoid="CreateArrayFromList"><a href="https://tc39.es/ecma262/#sec-createarrayfromlist">CreateArrayFromList</a></emu-xref>(« <var>subject</var> »).</li><li>Return <emu-xref aoid="CreateArrayFromList"><a href="https://tc39.es/ecma262/#sec-createarrayfromlist">CreateArrayFromList</a></emu-xref>(« <var>subject</var>.<var class="field">[[SymbolData]]</var> »).</li></ol></emu-alg>
</emu-clause>
</emu-clause>
<emu-note type="editor"><span class="note">Editor's Note</span><div class="note-contents">
Another approach is to ignore boxed primitives and only match primitive values.
</div></emu-note>
</emu-clause>
<emu-clause class="fold" id="sec-error-objects" number="5">
<h1><span class="secnum">20.5</span> Error Objects</h1>
<emu-clause id="sec-error-constructor" number="1">
<h1><span class="secnum">20.5.1</span> The Error Constructor</h1>
<emu-clause id="sec-error-message">
<h1><span class="secnum">20.5.1.1</span> Error ( <var>message</var> [ , <var>options</var> ] )</h1>
<p>This function performs the following steps when called:</p>
<emu-alg><ol><li>If NewTarget is <emu-val>undefined</emu-val>, let <var>newTarget</var> be the <emu-xref href="#active-function-object"><a href="https://tc39.es/ecma262/#active-function-object">active function object</a></emu-xref>; else let <var>newTarget</var> be NewTarget.</li><li>Let <var>O</var> be ? <emu-xref aoid="OrdinaryCreateFromConstructor"><a href="https://tc39.es/ecma262/#sec-ordinarycreatefromconstructor" class="e-user-code">OrdinaryCreateFromConstructor</a></emu-xref>(<var>newTarget</var>, <emu-val>"%Error.prototype%"</emu-val>, « <var class="field">[[ErrorData]]</var> »).</li><li><ins>Set <var>O</var>.<var class="field">[[ErrorData]]</var> to <emu-val>"Error"</emu-val>.</ins></li><li>If <var>message</var> is not <emu-val>undefined</emu-val>, then<ol><li>Let <var>msg</var> be ? <emu-xref aoid="ToString"><a href="https://tc39.es/ecma262/#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>message</var>).</li><li>Perform <emu-xref aoid="CreateNonEnumerableDataPropertyOrThrow"><a href="https://tc39.es/ecma262/#sec-createnonenumerabledatapropertyorthrow">CreateNonEnumerableDataPropertyOrThrow</a></emu-xref>(<var>O</var>, <emu-val>"message"</emu-val>, <var>msg</var>).</li></ol></li><li>Perform ? <emu-xref aoid="InstallErrorCause"><a href="https://tc39.es/ecma262/#sec-installerrorcause" class="e-user-code">InstallErrorCause</a></emu-xref>(<var>O</var>, <var>options</var>).</li><li>Return <var>O</var>.</li></ol></emu-alg>
</emu-clause>
</emu-clause>
<emu-clause id="sec-properties-of-the-error-constructors" number="2">
<h1><span class="secnum">20.5.2</span> Properties of the Error Constructor</h1>
<emu-clause id="sec-error-%symbol.custommatcher%" number="2">
<h1><span class="secnum">20.5.2.2</span> Error [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</h1>
<p>This function performs the following steps when called:</p>
<emu-alg><ol><li>Perform ? <emu-xref aoid="ValidateCustomMatcherHint" id="_ref_42"><a href="#sec-validatecustommatcherhint">ValidateCustomMatcherHint</a></emu-xref>(<var>hint</var>, <emu-const>boolean</emu-const>).</li><li>If <var>subject</var> does not have a <var class="field">[[ErrorData]]</var> internal slot, return <emu-val>false</emu-val>.</li><li>Return <emu-val>true</emu-val>.</li></ol></emu-alg>
</emu-clause>
<emu-note type="editor"><span class="note">Editor's Note</span><div class="note-contents">
It is possible to provide extractor semantics for Error matchers.
<pre><code class="javascript hljs"><span class="hljs-keyword">if</span> (expr is <span class="hljs-title class_">Error</span>(<span class="hljs-keyword">let</span> message, { <span class="hljs-keyword">let</span> cause })) {}</code></pre>
</div></emu-note>
</emu-clause>
<emu-clause id="sec-properties-of-error-instances" number="4">
<h1><span class="secnum">20.5.4</span> Properties of Error Instances</h1>
<p>Error instances are <emu-xref href="#ordinary-object"><a href="https://tc39.es/ecma262/#ordinary-object">ordinary objects</a></emu-xref> that inherit properties from the <emu-xref href="#sec-properties-of-the-error-prototype-object"><a href="https://tc39.es/ecma262/#sec-properties-of-the-error-prototype-object">Error prototype object</a></emu-xref> and have an
<var class="field">[[ErrorData]]</var> internal slot whose value is <del><emu-val>undefined</emu-val></del> <ins>a String</ins>. The only specified uses of
<var class="field">[[ErrorData]]</var> is to identify Error, AggregateError, and <var>NativeError</var> instances as Error objects within
<code>Object.prototype.toString</code> <ins>and their <emu-xref href="#sec-well-known-symbols" id="_ref_43"><a href="#sec-well-known-symbols">%Symbol.customMatcher%</a></emu-xref> methods</ins>.</p>
<emu-note type="editor"><span class="note">Editor's Note</span><div class="note-contents">
Rename this internal slot to <var class="field">[[ErrorKind]]</var>.
</div></emu-note>
</emu-clause>
<emu-clause id="sec-nativeerror-object-structure" number="6">
<h1><span class="secnum">20.5.6</span> <var>NativeError</var> Object Structure</h1>
<emu-clause id="sec-nativeerror-constructors" number="1">
<h1><span class="secnum">20.5.6.1</span> The <var>NativeError</var> Constructors</h1>
<emu-clause id="sec-nativeerror" number="1">
<h1><span class="secnum">20.5.6.1.1</span> <var>NativeError</var> ( <var>message</var> [ , <var>options</var> ] )</h1>
<p>Each <var>NativeError</var> function performs the following steps when called:</p>
<emu-alg><ol><li>If NewTarget is <emu-val>undefined</emu-val>, let <var>newTarget</var> be the <emu-xref href="#active-function-object"><a href="https://tc39.es/ecma262/#active-function-object">active function object</a></emu-xref>; else let <var>newTarget</var> be NewTarget.</li><li>Let <var>O</var> be ? <emu-xref aoid="OrdinaryCreateFromConstructor"><a href="https://tc39.es/ecma262/#sec-ordinarycreatefromconstructor" class="e-user-code">OrdinaryCreateFromConstructor</a></emu-xref>(<var>newTarget</var>, <code>"%<var>NativeError</var>.prototype%"</code>, « <var class="field">[[ErrorData]]</var> »).</li><li><ins>Set <var>O</var>.<var class="field">[[ErrorData]]</var> to <var>NativeError</var>.</ins></li><li>If <var>message</var> is not <emu-val>undefined</emu-val>, then<ol><li>Let <var>msg</var> be ? <emu-xref aoid="ToString"><a href="https://tc39.es/ecma262/#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>message</var>).</li><li>Perform <emu-xref aoid="CreateNonEnumerableDataPropertyOrThrow"><a href="https://tc39.es/ecma262/#sec-createnonenumerabledatapropertyorthrow">CreateNonEnumerableDataPropertyOrThrow</a></emu-xref>(<var>O</var>, <emu-val>"message"</emu-val>, <var>msg</var>).</li></ol></li><li>Perform ? <emu-xref aoid="InstallErrorCause"><a href="https://tc39.es/ecma262/#sec-installerrorcause" class="e-user-code">InstallErrorCause</a></emu-xref>(<var>O</var>, <var>options</var>).</li><li>Return <var>O</var>.</li></ol></emu-alg>
</emu-clause>
</emu-clause>
<emu-clause id="sec-properties-of-the-nativeerror-constructors" number="2">
<h1><span class="secnum">20.5.6.2</span> Properties of the <var>NativeError</var> Constructors</h1>
<emu-clause id="sec-nativeerror-%symbol.custommatcher%" number="2">
<h1><span class="secnum">20.5.6.2.2</span> <var>NativeError</var> [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</h1>
<emu-alg><ol><li>Perform ? <emu-xref aoid="ValidateCustomMatcherHint" id="_ref_44"><a href="#sec-validatecustommatcherhint">ValidateCustomMatcherHint</a></emu-xref>(<var>hint</var>, <emu-const>boolean</emu-const>).</li><li>If <var>subject</var> does not have a <var class="field">[[ErrorData]]</var> internal slot or <var>subject</var>.<var class="field">[[ErrorData]]</var> is not <var>NativeError</var>, return <emu-val>false</emu-val>.</li><li>Return <emu-val>true</emu-val>.</li></ol></emu-alg>
</emu-clause>
</emu-clause>
<emu-clause id="sec-properties-of-nativeerror-instances" number="4">
<h1><span class="secnum">20.5.6.4</span> Properties of <var>NativeError</var> Instances</h1>
<p><var>NativeError</var> instances are <emu-xref href="#ordinary-object"><a href="https://tc39.es/ecma262/#ordinary-object">ordinary objects</a></emu-xref> that inherit properties from their <var>NativeError</var> prototype object and
have an <var class="field">[[ErrorData]]</var> internal slot whose value is <del><emu-val>undefined</emu-val></del> <ins>a String</ins>. The only specified use
of <var class="field">[[ErrorData]]</var> is by <code>Object.prototype.toString</code> (<emu-xref href="#sec-object.prototype.tostring"><a href="https://tc39.es/ecma262/#sec-object.prototype.tostring">20.1.3.6</a></emu-xref>)
<ins>and their <emu-xref href="#sec-well-known-symbols" id="_ref_45"><a href="#sec-well-known-symbols">%Symbol.customMatcher%</a></emu-xref> methods</ins> to identify Error, AggregateError, or <var>NativeError</var> instances.
</p>
</emu-clause>
</emu-clause>
<emu-clause id="sec-aggregate-error-objects" number="7">
<h1><span class="secnum">20.5.7</span> AggregateError Objects</h1>
<emu-clause id="sec-aggregate-error-constructor" number="1">
<h1><span class="secnum">20.5.7.1</span> The AggregateError Constructor</h1>
<emu-clause id="sec-aggregate-error">
<h1><span class="secnum">20.5.7.1.1</span> AggregateError ( <var>errors</var>, <var>message</var> [ , <var>options</var> ] )</h1>
<p>This function performs the following steps when called:</p>
<emu-alg><ol><li>If NewTarget is <emu-val>undefined</emu-val>, let <var>newTarget</var> be the <emu-xref href="#active-function-object"><a href="https://tc39.es/ecma262/#active-function-object">active function object</a></emu-xref>; else let <var>newTarget</var> be NewTarget.</li><li>Let <var>O</var> be ? <emu-xref aoid="OrdinaryCreateFromConstructor"><a href="https://tc39.es/ecma262/#sec-ordinarycreatefromconstructor" class="e-user-code">OrdinaryCreateFromConstructor</a></emu-xref>(<var>newTarget</var>, <emu-val>"%AggregateError.prototype%"</emu-val>, « <var class="field">[[ErrorData]]</var> »).</li><li><ins>Set <var>O</var>.<var class="field">[[ErrorData]]</var> to <emu-val>"AggregateError"</emu-val>.</ins></li><li>If <var>message</var> is not <emu-val>undefined</emu-val>, then<ol><li>Let <var>msg</var> be ? <emu-xref aoid="ToString"><a href="https://tc39.es/ecma262/#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>message</var>).</li><li>Perform <emu-xref aoid="CreateNonEnumerableDataPropertyOrThrow"><a href="https://tc39.es/ecma262/#sec-createnonenumerabledatapropertyorthrow">CreateNonEnumerableDataPropertyOrThrow</a></emu-xref>(<var>O</var>, <emu-val>"message"</emu-val>, <var>msg</var>).</li></ol></li><li>Perform ? <emu-xref aoid="InstallErrorCause"><a href="https://tc39.es/ecma262/#sec-installerrorcause" class="e-user-code">InstallErrorCause</a></emu-xref>(<var>O</var>, <var>options</var>).</li><li>Let <var>errorsList</var> be ? <emu-xref aoid="IteratorToList"><a href="https://tc39.es/ecma262/#sec-iteratortolist" class="e-user-code">IteratorToList</a></emu-xref>(? <emu-xref aoid="GetIterator"><a href="https://tc39.es/ecma262/#sec-getiterator" class="e-user-code">GetIterator</a></emu-xref>(<var>errors</var>, <emu-const>sync</emu-const>)).</li><li>Perform ! <emu-xref aoid="DefinePropertyOrThrow"><a href="https://tc39.es/ecma262/#sec-definepropertyorthrow">DefinePropertyOrThrow</a></emu-xref>(<var>O</var>, <emu-val>"errors"</emu-val>, PropertyDescriptor { <var class="field">[[Configurable]]</var>: <emu-val>true</emu-val>, <var class="field">[[Enumerable]]</var>: <emu-val>false</emu-val>, <var class="field">[[Writable]]</var>: <emu-val>true</emu-val>, <var class="field">[[Value]]</var>: <emu-xref aoid="CreateArrayFromList"><a href="https://tc39.es/ecma262/#sec-createarrayfromlist">CreateArrayFromList</a></emu-xref>(<var>errorsList</var>) }).</li><li>Return <var>O</var>.</li></ol></emu-alg>
</emu-clause>
</emu-clause>
<emu-clause id="sec-properties-of-the-aggregate-error-constructors" number="2">
<h1><span class="secnum">20.5.7.2</span> Properties of the AggregateError Constructor</h1>
<emu-clause id="sec-aggregate-error-%symbol.custommatcher%" number="2">
<h1><span class="secnum">20.5.7.2.2</span> AggregateError [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</h1>
<emu-alg><ol><li>Perform ? <emu-xref aoid="ValidateCustomMatcherHint" id="_ref_46"><a href="#sec-validatecustommatcherhint">ValidateCustomMatcherHint</a></emu-xref>(<var>hint</var>, <emu-const>boolean</emu-const>).</li><li>If <var>subject</var> does not have a <var class="field">[[ErrorData]]</var> internal slot or <var>subject</var>.<var class="field">[[ErrorData]]</var> is not <emu-val>"AggregateError"</emu-val>, return <emu-val>false</emu-val>.</li><li>Return <emu-val>true</emu-val>.</li></ol></emu-alg>
</emu-clause>
</emu-clause>
<emu-clause id="sec-properties-of-aggregate-error-instances" number="4">
<h1><span class="secnum">20.5.7.4</span> Properties of AggregateError Instances</h1>
<p>AggregateError instances are <emu-xref href="#ordinary-object"><a href="https://tc39.es/ecma262/#ordinary-object">ordinary objects</a></emu-xref> that inherit properties from their <emu-xref href="#sec-properties-of-the-aggregate-error-prototype-objects"><a href="https://tc39.es/ecma262/#sec-properties-of-the-aggregate-error-prototype-objects">AggregateError prototype object</a></emu-xref> and
have an <var class="field">[[ErrorData]]</var> internal slot whose value is <del><emu-val>undefined</emu-val></del> <ins>a String</ins>. The only specified use
of <var class="field">[[ErrorData]]</var> is by <code>Object.prototype.toString</code> (<emu-xref href="#sec-object.prototype.tostring"><a href="https://tc39.es/ecma262/#sec-object.prototype.tostring">20.1.3.6</a></emu-xref>)
<ins>and their <emu-xref href="#sec-well-known-symbols" id="_ref_47"><a href="#sec-well-known-symbols">%Symbol.customMatcher%</a></emu-xref> methods</ins> to identify Error, AggregateError, or <var>NativeError</var> instances.
</p>
</emu-clause>
</emu-clause>
</emu-clause>
</emu-clause>
<emu-clause class="fold" id="sec-numbers-and-dates" number="21">
<h1><span class="secnum">21</span> Numbers and Dates</h1>
<emu-clause id="sec-number-objects" number="1">
<h1><span class="secnum">21.1</span> Number Objects</h1>
<emu-clause id="sec-properties-of-the-number-constructor" number="2">
<h1><span class="secnum">21.1.2</span> Properties of the Number Constructor</h1>
<emu-clause id="sec-number-%symbol.custommatcher%" number="16">
<h1><span class="secnum">21.1.2.16</span> Number [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</h1>
<p>This function performs the following steps when called:</p>
<emu-alg><ol><li>Perform ? <emu-xref aoid="ValidateCustomMatcherHint" id="_ref_48"><a href="#sec-validatecustommatcherhint">ValidateCustomMatcherHint</a></emu-xref>(<var>hint</var>).</li><li>If <var>subject</var> <emu-xref href="#sec-ecmascript-language-types-number-type"><a href="https://tc39.es/ecma262/#sec-ecmascript-language-types-number-type">is not a Number</a></emu-xref> and does not have a <var class="field">[[NumberData]]</var> internal slot, return <emu-val>false</emu-val>.</li><li>If <var>hint</var> is <emu-val>"boolean"</emu-val>, return <emu-val>true</emu-val>.</li><li>If <var>subject</var> <emu-xref href="#sec-ecmascript-language-types-number-type"><a href="https://tc39.es/ecma262/#sec-ecmascript-language-types-number-type">is a Number</a></emu-xref>, return <emu-xref aoid="CreateArrayFromList"><a href="https://tc39.es/ecma262/#sec-createarrayfromlist">CreateArrayFromList</a></emu-xref>(« <var>subject</var> »).</li><li>Return <emu-xref aoid="CreateArrayFromList"><a href="https://tc39.es/ecma262/#sec-createarrayfromlist">CreateArrayFromList</a></emu-xref>(« <var>subject</var>.<var class="field">[[NumberData]]</var> »).</li></ol></emu-alg>
</emu-clause>
<emu-note type="editor"><span class="note">Editor's Note</span><div class="note-contents">
Another approach is to ignore boxed primitives and only match primitive values.
</div></emu-note>
</emu-clause>
</emu-clause>
<emu-clause id="sec-bigint-objects" number="2">
<h1><span class="secnum">21.2</span> BigInt Objects</h1>
<emu-clause id="sec-properties-of-the-bigint-constructor" number="2">
<h1><span class="secnum">21.2.2</span> Properties of the BigInt Constructor</h1>
<emu-clause id="sec-bigint-%symbol.custommatcher%" number="4">
<h1><span class="secnum">21.2.2.4</span> BigInt [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</h1>
<p>This function performs the following steps when called:</p>
<emu-alg><ol><li>Perform ? <emu-xref aoid="ValidateCustomMatcherHint" id="_ref_49"><a href="#sec-validatecustommatcherhint">ValidateCustomMatcherHint</a></emu-xref>(<var>hint</var>).</li><li>If <var>subject</var> <emu-xref href="#sec-ecmascript-language-types-bigint-type"><a href="https://tc39.es/ecma262/#sec-ecmascript-language-types-bigint-type">is not a BigInt</a></emu-xref> and does not have a <var class="field">[[BigIntData]]</var> internal slot, return <emu-val>false</emu-val>.</li><li>If <var>hint</var> is <emu-val>"boolean"</emu-val>, return <emu-val>true</emu-val>.</li><li>If <var>subject</var> <emu-xref href="#sec-ecmascript-language-types-bigint-type"><a href="https://tc39.es/ecma262/#sec-ecmascript-language-types-bigint-type">is a BigInt</a></emu-xref>, return <emu-xref aoid="CreateArrayFromList"><a href="https://tc39.es/ecma262/#sec-createarrayfromlist">CreateArrayFromList</a></emu-xref>(« <var>subject</var> »).</li><li>Return <emu-xref aoid="CreateArrayFromList"><a href="https://tc39.es/ecma262/#sec-createarrayfromlist">CreateArrayFromList</a></emu-xref>(« <var>subject</var>.<var class="field">[[BigIntData]]</var> »).</li></ol></emu-alg>
</emu-clause>
</emu-clause>
<emu-note type="editor"><span class="note">Editor's Note</span><div class="note-contents">
Another approach is to ignore boxed primitives and only match primitive values.
</div></emu-note>
</emu-clause>
<emu-clause id="sec-date-objects" number="4">
<h1><span class="secnum">21.4</span> Date Objects</h1>
<emu-clause id="sec-properties-of-the-date-constructor" number="3">
<h1><span class="secnum">21.4.3</span> Properties of the Date Constructor</h1>
<emu-clause id="sec-date-%symbol.custommatcher%" number="5">
<h1><span class="secnum">21.4.3.5</span> Date [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</h1>
<p>This function performs the following steps when called:</p>
<emu-alg><ol><li>Perform ? <emu-xref aoid="ValidateCustomMatcherHint" id="_ref_50"><a href="#sec-validatecustommatcherhint">ValidateCustomMatcherHint</a></emu-xref>(<var>hint</var>, <emu-const>boolean</emu-const>).</li><li>If <var>subject</var> does not have a <var class="field">[[DateValue]]</var> internal slot, return <emu-val>false</emu-val>.</li><li>Return <emu-val>true</emu-val>.</li></ol></emu-alg>
</emu-clause>
</emu-clause>
</emu-clause>
</emu-clause>
<emu-clause class="fold" id="sec-text-processing" number="22">
<h1><span class="secnum">22</span> Text Processing</h1>
<emu-clause id="sec-string-objects" number="1">
<h1><span class="secnum">22.1</span> String Objects</h1>
<emu-clause id="sec-properties-of-the-string-constructor" number="2">
<h1><span class="secnum">22.1.2</span> Properties of the String Constructor</h1>
<emu-clause id="sec-string-%symbol.custommatcher%" number="5">
<h1><span class="secnum">22.1.2.5</span> String [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</h1>
<p>This function performs the following steps when called:</p>
<emu-alg><ol><li>Perform ? <emu-xref aoid="ValidateCustomMatcherHint" id="_ref_51"><a href="#sec-validatecustommatcherhint">ValidateCustomMatcherHint</a></emu-xref>(<var>hint</var>).</li><li>If <var>subject</var> <emu-xref href="#sec-ecmascript-language-types-string-type"><a href="https://tc39.es/ecma262/#sec-ecmascript-language-types-string-type">is not a String</a></emu-xref> and does not have a <var class="field">[[StringData]]</var> internal slot, return <emu-val>false</emu-val>.</li><li>If <var>hint</var> is <emu-val>"boolean"</emu-val>, return <emu-val>true</emu-val>.</li><li>If <var>subject</var> <emu-xref href="#sec-ecmascript-language-types-string-type"><a href="https://tc39.es/ecma262/#sec-ecmascript-language-types-string-type">is a String</a></emu-xref>, return <emu-xref aoid="CreateArrayFromList"><a href="https://tc39.es/ecma262/#sec-createarrayfromlist">CreateArrayFromList</a></emu-xref>(« <var>subject</var> »).</li><li>Return <emu-xref aoid="CreateArrayFromList"><a href="https://tc39.es/ecma262/#sec-createarrayfromlist">CreateArrayFromList</a></emu-xref>(« <var>subject</var>.<var class="field">[[StringData]]</var> »).</li></ol></emu-alg>
</emu-clause>
<emu-note type="editor"><span class="note">Editor's Note</span><div class="note-contents">
Another approach is to ignore boxed primitives and only match primitive values.
</div></emu-note>
</emu-clause>
</emu-clause>
<emu-clause id="sec-regexp-regular-expression-objects" number="2">
<h1><span class="secnum">22.2</span> RegExp (Regular Expression) Objects</h1>
<emu-clause id="sec-properties-of-the-regexp-constructor" number="5">
<h1><span class="secnum">22.2.5</span> Properties of the RegExp Constructor</h1>
<emu-clause id="sec-regexp-%symbol.custommatcher%" number="3">
<h1><span class="secnum">22.2.5.3</span> RegExp [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</h1>
<p>This function performs the following steps when called:</p>
<emu-alg><ol><li>Perform ? <emu-xref aoid="ValidateCustomMatcherHint" id="_ref_52"><a href="#sec-validatecustommatcherhint">ValidateCustomMatcherHint</a></emu-xref>(<var>hint</var>, <emu-const>boolean</emu-const>).</li><li>If ? <emu-xref aoid="IsRegExp"><a href="https://tc39.es/ecma262/#sec-isregexp" class="e-user-code">IsRegExp</a></emu-xref>(<var>subject</var>) is <emu-val>false</emu-val>, return <emu-val>false</emu-val>.</li><li>Return <emu-val>true</emu-val>.</li></ol></emu-alg>
<emu-note><span class="note">Note</span><div class="note-contents">
<emu-xref aoid="IsRegExp"><a href="https://tc39.es/ecma262/#sec-isregexp">IsRegExp</a></emu-xref> returns <emu-val>true</emu-val> for objects that have a truthy <emu-xref href="#sec-well-known-symbols" id="_ref_53"><a href="#sec-well-known-symbols">%Symbol.match%</a></emu-xref> property. Do we want this?
</div></emu-note>
</emu-clause>
</emu-clause>
<emu-clause id="sec-properties-of-the-regexp-prototype-object" number="6">
<h1><span class="secnum">22.2.6</span> Properties of the RegExp Prototype Object</h1>
<emu-clause id="sec-regexp.prototype-%symbol.custommatcher%" number="20">
<h1><span class="secnum">22.2.6.20</span> RegExp.prototype [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</h1>
<p>This function performs the following steps when called:</p>
<emu-alg><ol><li>Perform ? <emu-xref aoid="ValidateCustomMatcherHint" id="_ref_54"><a href="#sec-validatecustommatcherhint">ValidateCustomMatcherHint</a></emu-xref>(<var>hint</var>).</li><li>Let <var>regexp</var> be <emu-val>this</emu-val> value.</li><li>If <var>hint</var> is <emu-val>"boolean"</emu-val>, return ? <emu-xref aoid="Call"><a href="https://tc39.es/ecma262/#sec-call" class="e-user-code">Call</a></emu-xref>(? <emu-xref aoid="Get"><a href="https://tc39.es/ecma262/#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>regexp</var>, <emu-val>"test"</emu-val>), <var>regexp</var>, « <var>subject</var> »).</li><li>Let <var>isRegExp</var> be ? <emu-xref aoid="IsRegExp"><a href="https://tc39.es/ecma262/#sec-isregexp" class="e-user-code">IsRegExp</a></emu-xref>(<var>regexp</var>).</li><li>If <var>isRegExp</var> is <emu-val>true</emu-val>, then<ol><li>Let <var>flags</var> be ? <emu-xref aoid="Get"><a href="https://tc39.es/ecma262/#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>regexp</var>, "flags").</li><li>Perform ? <emu-xref aoid="RequireObjectCoercible"><a href="https://tc39.es/ecma262/#sec-requireobjectcoercible">RequireObjectCoercible</a></emu-xref>(<var>flags</var>).</li><li>If ? <emu-xref aoid="ToString"><a href="https://tc39.es/ecma262/#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>flags</var>) contains <emu-val>g</emu-val>, then<ol><li>Let <var>iterator</var> be ? <emu-xref aoid="Call"><a href="https://tc39.es/ecma262/#sec-call" class="e-user-code">Call</a></emu-xref>(? <emu-xref aoid="Get"><a href="https://tc39.es/ecma262/#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>regexp</var>, <emu-xref href="#sec-well-known-symbols" id="_ref_55"><a href="#sec-well-known-symbols">%Symbol.matchAll%</a></emu-xref>), <var>regexp</var>, « <var>subject</var> »).</li><li>Let <var>array</var> be ? <emu-xref aoid="Call"><a href="https://tc39.es/ecma262/#sec-call" class="e-user-code">Call</a></emu-xref>(<emu-xref href="#sec-array.from"><a href="https://tc39.es/ecma262/#sec-array.from">%Array.from%</a></emu-xref>, <emu-xref href="#sec-array-constructor"><a href="https://tc39.es/ecma262/#sec-array-constructor">%Array%</a></emu-xref>, « <var>iterator</var> »).</li><li>If ! <emu-xref aoid="LengthOfArrayLike"><a href="https://tc39.es/ecma262/#sec-lengthofarraylike">LengthOfArrayLike</a></emu-xref>(<var>array</var>) is 0, return <emu-val>false</emu-val>.</li><li>Return <var>array</var>.</li></ol></li></ol></li><li>Let <var>result</var> be ? <emu-xref aoid="Call"><a href="https://tc39.es/ecma262/#sec-call" class="e-user-code">Call</a></emu-xref>(? <emu-xref aoid="Get"><a href="https://tc39.es/ecma262/#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>regexp</var>, <emu-xref href="#sec-well-known-symbols" id="_ref_56"><a href="#sec-well-known-symbols">%Symbol.match%</a></emu-xref>), <var>regexp</var>, « <var>subject</var> »).</li><li>If <var>result</var> is <emu-val>null</emu-val>, return <emu-val>false</emu-val>.</li><li>Return <emu-xref aoid="CreateArrayFromList"><a href="https://tc39.es/ecma262/#sec-createarrayfromlist">CreateArrayFromList</a></emu-xref>(« <var>result</var> »).</li></ol></emu-alg>
<emu-note code=""><span class="note">Note</span><div class="note-contents">
<pre><code class="javascript hljs"><span class="hljs-keyword">let</span> regex = <span class="hljs-regexp">/(?<id>\d+)-?/g</span>
<span class="hljs-string">'012-345'</span> is <span class="hljs-title function_">regex</span>([<span class="hljs-string">"012-"</span>, <span class="hljs-string">"012"</span>], { <span class="hljs-attr">groups</span>: { <span class="hljs-attr">id</span>: <span class="hljs-string">"345"</span> } });
<span class="hljs-comment">// true, match with %Symbol.matchAll%</span>
<span class="hljs-keyword">let</span> regex2 = <span class="hljs-regexp">/(?<id>\d+)-?/</span>
<span class="hljs-string">'012-345'</span> is <span class="hljs-title function_">regex</span>({ <span class="hljs-attr">groups</span>: { <span class="hljs-attr">id</span>: <span class="hljs-string">"012"</span> } });
<span class="hljs-comment">// true, match with %Symbol.match%</span></code></pre>
</div></emu-note>
<emu-note type="editor"><span class="note">Editor's Note</span><div class="note-contents">
The <emu-val>"flags"</emu-val> property in this algorithm is accessed twice, this is not ideal.
Another access is
in <emu-xref href="#sec-regexp-prototype-%symbol.matchall%" title=""><a href="https://tc39.es/ecma262/#sec-regexp-prototype-%symbol.matchall%">RegExp.prototype [ %Symbol.matchAll% ] ( <var>string</var> )</a></emu-xref>
or <emu-xref href="#sec-regexp.prototype-%symbol.match%" title=""><a href="https://tc39.es/ecma262/#sec-regexp.prototype-%symbol.match%">RegExp.prototype [ %Symbol.match% ] ( <var>string</var> )</a></emu-xref>
depends on if the <var>regexp</var> has the <emu-val>g</emu-val> flag.
</div></emu-note>
<emu-note type="editor"><span class="note">Editor's Note</span><div class="note-contents">
When matching with a RegExp that <emu-val>"flags"</emu-val> contains <emu-val>"g"</emu-val>,
both <emu-xref href="#sec-%regexpstringiteratorprototype%.next" title=""><a href="https://tc39.es/ecma262/#sec-%regexpstringiteratorprototype%.next">%RegExpStringIteratorPrototype%.next ( )</a></emu-xref>
and <emu-xref href="#sec-%arrayiteratorprototype%.next" title=""><a href="https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next">%ArrayIteratorPrototype%.next ( )</a></emu-xref>
are called, this is not ideal.
</div></emu-note>
</emu-clause>
</emu-clause>
</emu-clause>
</emu-clause>
<emu-clause class="fold" id="sec-indexed-collections" number="23">
<h1><span class="secnum">23</span> Indexed Collections</h1>
<emu-clause id="sec-array-objects" number="1">
<h1><span class="secnum">23.1</span> Array Objects</h1>
<emu-clause id="sec-properties-of-the-array-constructor" number="2">
<h1><span class="secnum">23.1.2</span> Properties of the Array Constructor</h1>
<emu-clause id="sec-array-%symbol.custommatcher%" number="6">
<h1><span class="secnum">23.1.2.6</span> Array [ %Symbol.customMatcher% ] ( <var>subject</var>, <var>hint</var> )</h1>
<p>This function performs the following steps when called:</p>
<emu-alg><ol><li>Perform ? <emu-xref aoid="ValidateCustomMatcherHint" id="_ref_57"><a href="#sec-validatecustommatcherhint">ValidateCustomMatcherHint</a></emu-xref>(<var>hint</var>).</li><li>If ? <emu-xref aoid="IsArray"><a href="https://tc39.es/ecma262/#sec-isarray">IsArray</a></emu-xref>(<var>subject</var>) is <emu-val>false</emu-val>, return <emu-val>false</emu-val>.</li><li>If <var>hint</var> is <emu-val>"boolean"</emu-val>, return <emu-val>true</emu-val>.</li><li>Return <var>subject</var>.</li></ol></emu-alg>
<emu-note code=""><span class="note">Note</span><div class="note-contents"><pre><code class="javascript hljs"><span class="hljs-keyword">if</span> (expr is <span class="hljs-title class_">Array</span>(<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>)) {}</code></pre></div></emu-note>
</emu-clause>
</emu-clause>
</emu-clause>
<emu-clause id="sec-typedarray-objects" number="2">
<h1><span class="secnum">23.2</span> TypedArray Objects</h1>
<emu-clause id="sec-properties-of-the-typedarray-constructors" number="6">
<h1><span class="secnum">23.2.6</span> Properties of the <var>TypedArray</var> Constructors</h1>