forked from rse/es6-features
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
2351 lines (2311 loc) · 312 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>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<!--
es6-features ~~ ECMAScript 6 Feature Overview & Comparison
Copyright (c) 2015-2016 Ralf S. Engelschall <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-->
<title>ECMAScript 6: New Features: Overview and Comparison</title>
<script src="lib/jquery/jquery.js" type="text/javascript"></script>
<script src="lib/director/director.js" type="text/javascript"></script>
<script src="lib/mousetrap/mousetrap.js" type="text/javascript"></script>
<script src="index.js" type="text/javascript"></script>
<link href="index.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<a href="https://github.com/rse/es6-features">
<img style="position: fixed; top: 0; right: 0; border: 0; z-index: 2000;"
src="https://camo.githubusercontent.com/a6677b08c955af8400f44c6298f40e7d19cc5b2d/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f677261795f3664366436642e706e67"
alt="Fork me on GitHub"
data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png"/>
</a>
<iframe id="starbutton" src="https://ghbtns.com/github-btn.html?user=rse&repo=es6-features&type=star&count=true"
frameborder="0" scrolling="0" width="170px" height="20px">
</iframe>
<a class="twitter-share-button" href="https://twitter.com/share"
data-url="http://es6-features.org"
data-text="See how cleaner and more concise JavaScript can look and start coding in ECMAScript 6 now! @engelschall's"
data-hashtags="ES6"
data-related="engelschall"
>Tweet</a>
<script>
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>0
</script>
<div class="bg">ES6</div>
<div class="head">
<span class="bold">ECMAScript 6</span> — New Features: Overview & Comparison
</div>
<div class="slogan">
See how cleaner and more concise<br/>
your JavaScript code can look and<br/>
<a href="https://github.com/rse/es6-support">start coding</a> in <a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">ES6</a> <a href="https://github.com/rse/es6-support">now</a> !!
</div>
<div class="statement">
"A good programming language is a<br/>
conceptual universe for thinking<br/>
about programming." — Alan J. Perlis
</div>
<div class="nav">
<!-- ATTENTION: BEGIN OF GENERATED CODE. DO NOT EDIT MANUALLY -->
<ul>
<li class="title">Constants
<ul>
<li class="subtitle subtitle_Constants">
<a href="#Constants">Constants</a> <i class="fa fa-arrow-circle-right"></i></li>
</ul>
</li>
<li class="title">Scoping
<ul>
<li class="subtitle subtitle_BlockScopedVariables">
<a href="#BlockScopedVariables">Block-Scoped Variables</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_BlockScopedFunctions">
<a href="#BlockScopedFunctions">Block-Scoped Functions</a> <i class="fa fa-arrow-circle-right"></i></li>
</ul>
</li>
<li class="title">Arrow Functions
<ul>
<li class="subtitle subtitle_ExpressionBodies">
<a href="#ExpressionBodies">Expression Bodies</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_StatementBodies">
<a href="#StatementBodies">Statement Bodies</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_Lexicalthis">
<a href="#Lexicalthis">Lexical <code>this</code></a> <i class="fa fa-arrow-circle-right"></i></li>
</ul>
</li>
<li class="title">Extended Parameter Handling
<ul>
<li class="subtitle subtitle_DefaultParameterValues">
<a href="#DefaultParameterValues">Default Parameter Values</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_RestParameter">
<a href="#RestParameter">Rest Parameter</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_SpreadOperator">
<a href="#SpreadOperator">Spread Operator</a> <i class="fa fa-arrow-circle-right"></i></li>
</ul>
</li>
<li class="title">Template Literals
<ul>
<li class="subtitle subtitle_StringInterpolation">
<a href="#StringInterpolation">String Interpolation</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_CustomInterpolation">
<a href="#CustomInterpolation">Custom Interpolation</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_RawStringAccess">
<a href="#RawStringAccess">Raw String Access</a> <i class="fa fa-arrow-circle-right"></i></li>
</ul>
</li>
<li class="title">Extended Literals
<ul>
<li class="subtitle subtitle_BinaryOctalLiteral">
<a href="#BinaryOctalLiteral">Binary & Octal Literal</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_UnicodeStringRegExpLiteral">
<a href="#UnicodeStringRegExpLiteral">Unicode String & RegExp Literal</a> <i class="fa fa-arrow-circle-right"></i></li>
</ul>
</li>
<li class="title">Enhanced Regular Expression
<ul>
<li class="subtitle subtitle_RegularExpressionStickyMatching">
<a href="#RegularExpressionStickyMatching">Regular Expression Sticky Matching</a> <i class="fa fa-arrow-circle-right"></i></li>
</ul>
</li>
<li class="title">Enhanced Object Properties
<ul>
<li class="subtitle subtitle_PropertyShorthand">
<a href="#PropertyShorthand">Property Shorthand</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_ComputedPropertyNames">
<a href="#ComputedPropertyNames">Computed Property Names</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_MethodProperties">
<a href="#MethodProperties">Method Properties</a> <i class="fa fa-arrow-circle-right"></i></li>
</ul>
</li>
<li class="title">Destructuring Assignment
<ul>
<li class="subtitle subtitle_ArrayMatching">
<a href="#ArrayMatching">Array Matching</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_ObjectMatchingShorthandNotation">
<a href="#ObjectMatchingShorthandNotation">Object Matching, Shorthand Notation</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_ObjectMatchingDeepMatching">
<a href="#ObjectMatchingDeepMatching">Object Matching, Deep Matching</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_ObjectAndArrayMatchingDefaultValues">
<a href="#ObjectAndArrayMatchingDefaultValues">Object And Array Matching, Default Values</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_ParameterContextMatching">
<a href="#ParameterContextMatching">Parameter Context Matching</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_FailSoftDestructuring">
<a href="#FailSoftDestructuring">Fail-Soft Destructuring</a> <i class="fa fa-arrow-circle-right"></i></li>
</ul>
</li>
<li class="title">Modules
<ul>
<li class="subtitle subtitle_ValueExportImport">
<a href="#ValueExportImport">Value Export/Import</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_DefaultWildcard">
<a href="#DefaultWildcard">Default & Wildcard</a> <i class="fa fa-arrow-circle-right"></i></li>
</ul>
</li>
<li class="title">Classes
<ul>
<li class="subtitle subtitle_ClassDefinition">
<a href="#ClassDefinition">Class Definition</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_ClassInheritance">
<a href="#ClassInheritance">Class Inheritance</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_ClassInheritanceFromExpressions">
<a href="#ClassInheritanceFromExpressions">Class Inheritance, From Expressions</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_BaseClassAccess">
<a href="#BaseClassAccess">Base Class Access</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_StaticMembers">
<a href="#StaticMembers">Static Members</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_GetterSetter">
<a href="#GetterSetter">Getter/Setter</a> <i class="fa fa-arrow-circle-right"></i></li>
</ul>
</li>
<li class="title">Symbol Type
<ul>
<li class="subtitle subtitle_SymbolType">
<a href="#SymbolType">Symbol Type</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_GlobalSymbols">
<a href="#GlobalSymbols">Global Symbols</a> <i class="fa fa-arrow-circle-right"></i></li>
</ul>
</li>
<li class="title">Iterators
<ul>
<li class="subtitle subtitle_IteratorForOfOperator">
<a href="#IteratorForOfOperator">Iterator & For-Of Operator</a> <i class="fa fa-arrow-circle-right"></i></li>
</ul>
</li>
<li class="title">Generators
<ul>
<li class="subtitle subtitle_GeneratorFunctionIteratorProtocol">
<a href="#GeneratorFunctionIteratorProtocol">Generator Function, Iterator Protocol</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_GeneratorFunctionDirectUse">
<a href="#GeneratorFunctionDirectUse">Generator Function, Direct Use</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_GeneratorMatching">
<a href="#GeneratorMatching">Generator Matching</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_GeneratorControlFlow">
<a href="#GeneratorControlFlow">Generator Control-Flow</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_GeneratorMethods">
<a href="#GeneratorMethods">Generator Methods</a> <i class="fa fa-arrow-circle-right"></i></li>
</ul>
</li>
<li class="title">Map/Set & WeakMap/WeakSet
<ul>
<li class="subtitle subtitle_SetDataStructure">
<a href="#SetDataStructure">Set Data-Structure</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_MapDataStructure">
<a href="#MapDataStructure">Map Data-Structure</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_WeakLinkDataStructures">
<a href="#WeakLinkDataStructures">Weak-Link Data-Structures</a> <i class="fa fa-arrow-circle-right"></i></li>
</ul>
</li>
<li class="title">Typed Arrays
<ul>
<li class="subtitle subtitle_TypedArrays">
<a href="#TypedArrays">Typed Arrays</a> <i class="fa fa-arrow-circle-right"></i></li>
</ul>
</li>
<li class="title">New Built-In Methods
<ul>
<li class="subtitle subtitle_ObjectPropertyAssignment">
<a href="#ObjectPropertyAssignment">Object Property Assignment</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_ArrayElementFinding">
<a href="#ArrayElementFinding">Array Element Finding</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_StringRepeating">
<a href="#StringRepeating">String Repeating</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_StringSearching">
<a href="#StringSearching">String Searching</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_NumberTypeChecking">
<a href="#NumberTypeChecking">Number Type Checking</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_NumberSafetyChecking">
<a href="#NumberSafetyChecking">Number Safety Checking</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_NumberComparison">
<a href="#NumberComparison">Number Comparison</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_NumberTruncation">
<a href="#NumberTruncation">Number Truncation</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_NumberSignDetermination">
<a href="#NumberSignDetermination">Number Sign Determination</a> <i class="fa fa-arrow-circle-right"></i></li>
</ul>
</li>
<li class="title">Promises
<ul>
<li class="subtitle subtitle_PromiseUsage">
<a href="#PromiseUsage">Promise Usage</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_PromiseCombination">
<a href="#PromiseCombination">Promise Combination</a> <i class="fa fa-arrow-circle-right"></i></li>
</ul>
</li>
<li class="title">Meta-Programming
<ul>
<li class="subtitle subtitle_Proxying">
<a href="#Proxying">Proxying</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_Reflection">
<a href="#Reflection">Reflection</a> <i class="fa fa-arrow-circle-right"></i></li>
</ul>
</li>
<li class="title">Internationalization & Localization
<ul>
<li class="subtitle subtitle_Collation">
<a href="#Collation">Collation</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_NumberFormatting">
<a href="#NumberFormatting">Number Formatting</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_CurrencyFormatting">
<a href="#CurrencyFormatting">Currency Formatting</a> <i class="fa fa-arrow-circle-right"></i></li>
<li class="subtitle subtitle_DateTimeFormatting">
<a href="#DateTimeFormatting">Date/Time Formatting</a> <i class="fa fa-arrow-circle-right"></i></li>
</ul>
</li>
</ul>
<!-- ATTENTION: END OF GENERATED CODE. DO NOT EDIT MANUALLY -->
</div>
<div class="content">
<!-- ATTENTION: BEGIN OF GENERATED CODE. DO NOT EDIT MANUALLY -->
<div id="Constants" class="showcase showcase_Constants"> <div class="title">Constants</div>
<div class="subtitle">Constants</div>
<div class="desc">Support for constants (also known as "immutable variables"), i.e.,
variables which cannot be re-assigned new content. Notice: this only
makes the variable itself immutable, not its assigned content (for
instance, in case the content is an object, this means the object itself
can still be altered).</div>
<div class="js es6">
<div class="title"><b>ECMAScript 6</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code"><span class="mark"><span class="keyword">const</span> PI</span><span class="punctuation"> = </span><span class="literal">3</span><span class="punctuation">.</span><span class="literal">141593</span><span class="semi">;</span>
PI <span class="punctuation">></span> <span class="literal">3</span><span class="punctuation">.</span><span class="literal">0</span><span class="semi">;</span>
</div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-check-circle"></i>
</div>
<div class="arrow"><i class="fa fa-caret-up"></i><i class="fa fa-caret-down"></i></div><div class="js es5">
<div class="title"><b>ECMAScript 5</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code"><span class="comment">// only <span class="keyword">in</span> ES<span class="literal">5</span> through the help <span class="keyword">of</span> object properties</span><span class="comment">
// and only <span class="keyword">in</span> global context and not <span class="keyword">in</span> a block scope</span>
Object<span class="punctuation">.</span><span class="mark">defineProperty</span><span class="punctuation">(</span>typeof global <span class="punctuation">===</span> <span class="literal">"object"</span> ? global : window<span class="punctuation">,</span> <span class="literal">"<span class="mark">PI</span>"</span><span class="punctuation">,</span> <span class="punctuation">{</span>
value: <span class="literal">3</span><span class="punctuation">.</span><span class="literal">141593</span><span class="punctuation">,</span>
enumerable: true<span class="punctuation">,</span>
<span class="mark">writable: false</span><span class="punctuation">,</span>
<span class="mark">configurable: false</span>
<span class="punctuation">}</span><span class="punctuation">)</span>
PI <span class="punctuation">></span> <span class="literal">3</span><span class="punctuation">.</span><span class="literal">0</span><span class="semi">;</span></div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-times-circle"></i>
</div>
</div>
<div id="BlockScopedVariables" class="showcase showcase_BlockScopedVariables"> <div class="title">Scoping</div>
<div class="subtitle">Block-Scoped Variables</div>
<div class="desc">Block-scoped variables (and constants) without hoisting.</div>
<div class="js es6">
<div class="title"><b>ECMAScript 6</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code"><span class="keyword">for</span> <span class="punctuation">(</span><span class="mark"><span class="keyword">let</span> i</span><span class="punctuation"> = </span><span class="literal">0</span><span class="punctuation">;</span> i <span class="punctuation"><</span> a<span class="punctuation">.</span>length<span class="punctuation">;</span> i<span class="punctuation">+</span><span class="punctuation">+</span><span class="punctuation">)</span> <span class="punctuation">{</span>
<span class="mark"><span class="keyword">let</span> x</span><span class="punctuation"> = </span>a<span class="punctuation">[</span>i<span class="punctuation">]</span><span class="semi">;</span>
<span class="ellipsis">…</span>
<span class="punctuation">}</span>
<span class="keyword">for</span> <span class="punctuation">(</span><span class="mark"><span class="keyword">let</span> i</span><span class="punctuation"> = </span><span class="literal">0</span><span class="punctuation">;</span> i <span class="punctuation"><</span> b<span class="punctuation">.</span>length<span class="punctuation">;</span> i<span class="punctuation">+</span><span class="punctuation">+</span><span class="punctuation">)</span> <span class="punctuation">{</span>
<span class="mark"><span class="keyword">let</span> y</span><span class="punctuation"> = </span>b<span class="punctuation">[</span>i<span class="punctuation">]</span><span class="semi">;</span>
<span class="ellipsis">…</span>
<span class="punctuation">}</span>
<span class="keyword">let</span> callbacks<span class="punctuation"> = </span><span class="punctuation">[</span><span class="punctuation">]</span><span class="semi">;</span>
<span class="keyword">for</span> <span class="punctuation">(</span><span class="mark"><span class="keyword">let</span></span> i<span class="punctuation"> = </span><span class="literal">0</span><span class="punctuation">;</span> i <span class="punctuation"><</span>= <span class="literal">2</span><span class="punctuation">;</span> i<span class="punctuation">+</span><span class="punctuation">+</span><span class="punctuation">)</span> <span class="punctuation">{</span>
callbacks<span class="punctuation">[</span>i<span class="punctuation">]</span><span class="punctuation"> = </span><span class="keyword">function</span> <span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span> <span class="keyword">return</span> i <span class="punctuation">*</span> <span class="literal">2</span><span class="semi">;</span> <span class="punctuation">}</span><span class="semi">;</span>
<span class="punctuation">}</span>
callbacks<span class="punctuation">[</span><span class="literal">0</span><span class="punctuation">]</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">===</span> <span class="literal">0</span><span class="semi">;</span>
callbacks<span class="punctuation">[</span><span class="literal">1</span><span class="punctuation">]</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">===</span> <span class="literal">2</span><span class="semi">;</span>
callbacks<span class="punctuation">[</span><span class="literal">2</span><span class="punctuation">]</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">===</span> <span class="literal">4</span><span class="semi">;</span>
</div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-check-circle"></i>
</div>
<div class="arrow"><i class="fa fa-caret-up"></i><i class="fa fa-caret-down"></i></div><div class="js es5">
<div class="title"><b>ECMAScript 5</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code"><span class="mark"><span class="keyword">var</span> i<span class="punctuation">,</span> x<span class="punctuation">,</span> y</span><span class="semi">;</span>
<span class="keyword">for</span> <span class="punctuation">(</span>i<span class="punctuation"> = </span><span class="literal">0</span><span class="punctuation">;</span> i <span class="punctuation"><</span> a<span class="punctuation">.</span>length<span class="punctuation">;</span> i<span class="punctuation">+</span><span class="punctuation">+</span><span class="punctuation">)</span> <span class="punctuation">{</span>
x<span class="punctuation"> = </span>a<span class="punctuation">[</span>i<span class="punctuation">]</span><span class="semi">;</span>
<span class="ellipsis">…</span>
<span class="punctuation">}</span>
<span class="keyword">for</span> <span class="punctuation">(</span>i<span class="punctuation"> = </span><span class="literal">0</span><span class="punctuation">;</span> i <span class="punctuation"><</span> b<span class="punctuation">.</span>length<span class="punctuation">;</span> i<span class="punctuation">+</span><span class="punctuation">+</span><span class="punctuation">)</span> <span class="punctuation">{</span>
y<span class="punctuation"> = </span>b<span class="punctuation">[</span>i<span class="punctuation">]</span><span class="semi">;</span>
<span class="ellipsis">…</span>
<span class="punctuation">}</span>
<span class="keyword">var</span> callbacks<span class="punctuation"> = </span><span class="punctuation">[</span><span class="punctuation">]</span><span class="semi">;</span>
<span class="keyword">for</span> <span class="punctuation">(</span><span class="mark"><span class="keyword">var</span></span> i<span class="punctuation"> = </span><span class="literal">0</span><span class="punctuation">;</span> i <span class="punctuation"><</span>= <span class="literal">2</span><span class="punctuation">;</span> i<span class="punctuation">+</span><span class="punctuation">+</span><span class="punctuation">)</span> <span class="punctuation">{</span>
<span class="mark"><span class="punctuation">(</span><span class="keyword">function</span> <span class="punctuation">(</span>i<span class="punctuation">)</span> <span class="punctuation">{</span></span>
callbacks<span class="punctuation">[</span>i<span class="punctuation">]</span><span class="punctuation"> = </span><span class="keyword">function</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span> <span class="keyword">return</span> i <span class="punctuation">*</span> <span class="literal">2</span><span class="semi">;</span> <span class="punctuation">}</span><span class="semi">;</span>
<span class="mark"><span class="punctuation">}</span><span class="punctuation">)</span><span class="punctuation">(</span>i<span class="punctuation">)</span><span class="punctuation">;</span></span>
<span class="punctuation">}</span>
callbacks<span class="punctuation">[</span><span class="literal">0</span><span class="punctuation">]</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">===</span> <span class="literal">0</span><span class="semi">;</span>
callbacks<span class="punctuation">[</span><span class="literal">1</span><span class="punctuation">]</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">===</span> <span class="literal">2</span><span class="semi">;</span>
callbacks<span class="punctuation">[</span><span class="literal">2</span><span class="punctuation">]</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">===</span> <span class="literal">4</span><span class="semi">;</span></div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-times-circle"></i>
</div>
</div>
<div id="BlockScopedFunctions" class="showcase showcase_BlockScopedFunctions"> <div class="title">Scoping</div>
<div class="subtitle">Block-Scoped Functions</div>
<div class="desc">Block-scoped function definitions.</div>
<div class="js es6">
<div class="title"><b>ECMAScript 6</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code"><span class="punctuation">{</span>
<span class="keyword">function</span> foo <span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span> <span class="keyword">return</span> <span class="literal">1</span><span class="semi">;</span> <span class="punctuation">}</span>
foo<span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">===</span> <span class="literal">1</span><span class="semi">;</span>
<span class="punctuation">{</span>
<span class="keyword">function</span> <span class="mark">foo</span> <span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span> <span class="keyword">return</span> <span class="mark"><span class="literal">2</span></span><span class="semi">;</span> <span class="punctuation">}</span>
<span class="mark">foo</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">===</span> <span class="mark"><span class="literal">2</span></span><span class="semi">;</span>
<span class="punctuation">}</span>
foo<span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">===</span> <span class="literal">1</span><span class="semi">;</span>
<span class="punctuation">}</span>
</div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-check-circle"></i>
</div>
<div class="arrow"><i class="fa fa-caret-up"></i><i class="fa fa-caret-down"></i></div><div class="js es5">
<div class="title"><b>ECMAScript 5</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code"><span class="comment">// only <span class="keyword">in</span> ES<span class="literal">5</span> with the help <span class="keyword">of</span> block<span class="punctuation">-</span>scope emulating</span><span class="comment">
// <span class="keyword">function</span> scopes and <span class="keyword">function</span> expressions</span>
<span class="punctuation">(</span><span class="keyword">function</span> <span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span>
<span class="keyword">var</span> foo<span class="punctuation"> = </span><span class="keyword">function</span> <span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span> <span class="keyword">return</span> <span class="literal">1</span><span class="semi">;</span> <span class="punctuation">}</span>
foo<span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">===</span> <span class="literal">1</span><span class="semi">;</span>
<span class="mark"><span class="punctuation">(</span><span class="keyword">function</span> <span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span></span>
<span class="keyword">var</span> <span class="mark">foo</span><span class="punctuation"> = </span><span class="keyword">function</span> <span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span> <span class="keyword">return</span> <span class="mark"><span class="literal">2</span></span><span class="semi">;</span> <span class="punctuation">}</span>
<span class="mark">foo</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">===</span> <span class="mark"><span class="literal">2</span></span><span class="semi">;</span>
<span class="mark"><span class="punctuation">}</span><span class="punctuation">)</span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span></span>
foo<span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">===</span> <span class="literal">1</span><span class="semi">;</span>
<span class="punctuation">}</span><span class="punctuation">)</span><span class="punctuation">(</span><span class="punctuation">)</span><span class="semi">;</span></div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-times-circle"></i>
</div>
</div>
<div id="ExpressionBodies" class="showcase showcase_ExpressionBodies"> <div class="title">Arrow Functions</div>
<div class="subtitle">Expression Bodies</div>
<div class="desc">More expressive closure syntax.</div>
<div class="js es6">
<div class="title"><b>ECMAScript 6</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code">odds <span class="punctuation"> = </span>evens<span class="punctuation">.</span>map<span class="punctuation">(</span><span class="mark">v <span class="punctuation">=></span></span> v <span class="punctuation">+</span> <span class="literal">1</span><span class="punctuation">)</span><span class="semi">;</span>
pairs<span class="punctuation"> = </span>evens<span class="punctuation">.</span>map<span class="punctuation">(</span><span class="mark">v <span class="punctuation">=></span> <span class="punctuation">(</span></span><span class="punctuation">{</span> even: v<span class="punctuation">,</span> odd: v <span class="punctuation">+</span> <span class="literal">1</span> <span class="punctuation">}</span><span class="mark"><span class="punctuation">)</span></span><span class="punctuation">)</span><span class="semi">;</span>
nums <span class="punctuation"> = </span>evens<span class="punctuation">.</span>map<span class="punctuation">(</span><span class="mark"><span class="punctuation">(</span>v<span class="punctuation">,</span> i<span class="punctuation">)</span> <span class="punctuation">=></span></span> v <span class="punctuation">+</span> i<span class="punctuation">)</span><span class="semi">;</span>
</div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-check-circle"></i>
</div>
<div class="arrow"><i class="fa fa-caret-up"></i><i class="fa fa-caret-down"></i></div><div class="js es5">
<div class="title"><b>ECMAScript 5</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code">odds <span class="punctuation"> = </span>evens<span class="punctuation">.</span>map<span class="punctuation">(</span><span class="mark"><span class="keyword">function</span> <span class="punctuation">(</span>v<span class="punctuation">)</span> <span class="punctuation">{</span> <span class="keyword">return</span></span> v <span class="punctuation">+</span> <span class="literal">1</span><span class="semi">;</span> <span class="mark"><span class="punctuation">}</span></span><span class="punctuation">)</span><span class="semi">;</span>
pairs<span class="punctuation"> = </span>evens<span class="punctuation">.</span>map<span class="punctuation">(</span><span class="mark"><span class="keyword">function</span> <span class="punctuation">(</span>v<span class="punctuation">)</span> <span class="punctuation">{</span> <span class="keyword">return</span></span> <span class="punctuation">{</span> even: v<span class="punctuation">,</span> odd: v <span class="punctuation">+</span> <span class="literal">1</span> <span class="punctuation">}</span><span class="semi">;</span> <span class="mark"><span class="punctuation">}</span></span><span class="punctuation">)</span><span class="semi">;</span>
nums <span class="punctuation"> = </span>evens<span class="punctuation">.</span>map<span class="punctuation">(</span><span class="mark"><span class="keyword">function</span> <span class="punctuation">(</span>v<span class="punctuation">,</span> i<span class="punctuation">)</span> <span class="punctuation">{</span> <span class="keyword">return</span></span> v <span class="punctuation">+</span> i<span class="semi">;</span> <span class="mark"><span class="punctuation">}</span></span><span class="punctuation">)</span><span class="semi">;</span></div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-times-circle"></i>
</div>
</div>
<div id="StatementBodies" class="showcase showcase_StatementBodies"> <div class="title">Arrow Functions</div>
<div class="subtitle">Statement Bodies</div>
<div class="desc">More expressive closure syntax.</div>
<div class="js es6">
<div class="title"><b>ECMAScript 6</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code">nums<span class="punctuation">.</span>forEach<span class="punctuation">(</span><span class="mark">v <span class="punctuation">=></span> <span class="punctuation">{</span></span>
<span class="keyword">if</span> <span class="punctuation">(</span>v <span class="punctuation">%</span> <span class="literal">5</span> <span class="punctuation">===</span> <span class="literal">0</span><span class="punctuation">)</span>
fives<span class="punctuation">.</span>push<span class="punctuation">(</span>v<span class="punctuation">)</span><span class="semi">;</span>
<span class="mark"><span class="punctuation">}</span></span><span class="punctuation">)</span>
</div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-check-circle"></i>
</div>
<div class="arrow"><i class="fa fa-caret-up"></i><i class="fa fa-caret-down"></i></div><div class="js es5">
<div class="title"><b>ECMAScript 5</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code">nums<span class="punctuation">.</span>forEach<span class="punctuation">(</span><span class="mark"><span class="keyword">function</span> <span class="punctuation">(</span>v<span class="punctuation">)</span> <span class="punctuation">{</span></span>
<span class="keyword">if</span> <span class="punctuation">(</span>v <span class="punctuation">%</span> <span class="literal">5</span> <span class="punctuation">===</span> <span class="literal">0</span><span class="punctuation">)</span>
fives<span class="punctuation">.</span>push<span class="punctuation">(</span>v<span class="punctuation">)</span><span class="semi">;</span>
<span class="mark"><span class="punctuation">}</span></span><span class="punctuation">)</span><span class="semi">;</span></div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-times-circle"></i>
</div>
</div>
<div id="Lexicalthis" class="showcase showcase_Lexicalthis"> <div class="title">Arrow Functions</div>
<div class="subtitle">Lexical <code>this</code></div>
<div class="desc">More intuitive handling of current object context.</div>
<div class="js es6">
<div class="title"><b>ECMAScript 6</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code"><span class="mark"><span class="keyword">this</span></span><span class="punctuation">.</span>nums<span class="punctuation">.</span>forEach<span class="punctuation">(</span><span class="mark"><span class="punctuation">(</span>v<span class="punctuation">)</span> <span class="punctuation">=></span></span> <span class="punctuation">{</span>
<span class="keyword">if</span> <span class="punctuation">(</span>v <span class="punctuation">%</span> <span class="literal">5</span> <span class="punctuation">===</span> <span class="literal">0</span><span class="punctuation">)</span>
<span class="mark"><span class="keyword">this</span></span><span class="punctuation">.</span>fives<span class="punctuation">.</span>push<span class="punctuation">(</span>v<span class="punctuation">)</span><span class="semi">;</span>
<span class="punctuation">}</span><span class="punctuation">)</span><span class="semi">;</span>
</div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-check-circle"></i>
</div>
<div class="arrow"><i class="fa fa-caret-up"></i><i class="fa fa-caret-down"></i></div><div class="js es5">
<div class="title"><b>ECMAScript 5</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code"><span class="comment">// variant <span class="literal">1</span></span>
<span class="keyword">var</span> <span class="mark">self</span><span class="punctuation"> = </span><span class="mark"><span class="keyword">this</span></span><span class="semi">;</span>
<span class="mark"><span class="keyword">this</span></span><span class="punctuation">.</span>nums<span class="punctuation">.</span>forEach<span class="punctuation">(</span><span class="mark"><span class="keyword">function</span> <span class="punctuation">(</span>v<span class="punctuation">)</span></span> <span class="punctuation">{</span>
<span class="keyword">if</span> <span class="punctuation">(</span>v <span class="punctuation">%</span> <span class="literal">5</span> <span class="punctuation">===</span> <span class="literal">0</span><span class="punctuation">)</span>
<span class="mark">self</span><span class="punctuation">.</span>fives<span class="punctuation">.</span>push<span class="punctuation">(</span>v<span class="punctuation">)</span><span class="semi">;</span>
<span class="punctuation">}</span><span class="punctuation">)</span><span class="semi">;</span>
<span class="comment">
// variant <span class="literal">2</span></span>
<span class="mark"><span class="keyword">this</span></span><span class="punctuation">.</span>nums<span class="punctuation">.</span>forEach<span class="punctuation">(</span><span class="mark"><span class="keyword">function</span> <span class="punctuation">(</span>v<span class="punctuation">)</span></span> <span class="punctuation">{</span>
<span class="keyword">if</span> <span class="punctuation">(</span>v <span class="punctuation">%</span> <span class="literal">5</span> <span class="punctuation">===</span> <span class="literal">0</span><span class="punctuation">)</span>
<span class="mark"><span class="keyword">this</span></span><span class="punctuation">.</span>fives<span class="punctuation">.</span>push<span class="punctuation">(</span>v<span class="punctuation">)</span><span class="semi">;</span>
<span class="punctuation">}</span><span class="punctuation">,</span> <span class="mark"><span class="keyword">this</span></span><span class="punctuation">)</span><span class="semi">;</span>
<span class="comment">
// variant <span class="literal">3</span> <span class="punctuation">(</span>since ECMAScript <span class="literal">5</span><span class="punctuation">.</span><span class="literal">1</span> only<span class="punctuation">)</span></span>
<span class="mark"><span class="keyword">this</span></span><span class="punctuation">.</span>nums<span class="punctuation">.</span>forEach<span class="punctuation">(</span><span class="mark"><span class="keyword">function</span> <span class="punctuation">(</span>v<span class="punctuation">)</span></span> <span class="punctuation">{</span>
<span class="keyword">if</span> <span class="punctuation">(</span>v <span class="punctuation">%</span> <span class="literal">5</span> <span class="punctuation">===</span> <span class="literal">0</span><span class="punctuation">)</span>
<span class="mark"><span class="keyword">this</span></span><span class="punctuation">.</span>fives<span class="punctuation">.</span>push<span class="punctuation">(</span>v<span class="punctuation">)</span><span class="semi">;</span>
<span class="punctuation">}</span><span class="mark"><span class="punctuation">.</span>bind<span class="punctuation">(</span><span class="keyword">this</span><span class="punctuation">)</span></span><span class="punctuation">)</span><span class="semi">;</span></div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-times-circle"></i>
</div>
</div>
<div id="DefaultParameterValues" class="showcase showcase_DefaultParameterValues"> <div class="title">Extended Parameter Handling</div>
<div class="subtitle">Default Parameter Values</div>
<div class="desc">Simple and intuitive default values for function parameters.</div>
<div class="js es6">
<div class="title"><b>ECMAScript 6</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code"><span class="keyword">function</span> f <span class="punctuation">(</span>x<span class="punctuation">,</span> y <span class="mark">= <span class="literal">7</span></span><span class="punctuation">,</span> z <span class="mark">= <span class="literal">42</span></span><span class="punctuation">)</span> <span class="punctuation">{</span>
<span class="keyword">return</span> x <span class="punctuation">+</span> y <span class="punctuation">+</span> z<span class="semi">;</span>
<span class="punctuation">}</span>
f<span class="punctuation">(</span><span class="literal">1</span><span class="punctuation">)</span> <span class="punctuation">===</span> <span class="literal">50</span><span class="semi">;</span>
</div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-check-circle"></i>
</div>
<div class="arrow"><i class="fa fa-caret-up"></i><i class="fa fa-caret-down"></i></div><div class="js es5">
<div class="title"><b>ECMAScript 5</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code"><span class="keyword">function</span> f <span class="punctuation">(</span>x<span class="punctuation">,</span> y<span class="punctuation">,</span> z<span class="punctuation">)</span> <span class="punctuation">{</span>
<span class="mark"><span class="keyword">if</span> <span class="punctuation">(</span>y <span class="punctuation">===</span> undefined<span class="punctuation">)</span></span>
<span class="mark">y<span class="punctuation"> = </span><span class="literal">7</span></span><span class="semi">;</span>
<span class="mark"><span class="keyword">if</span> <span class="punctuation">(</span>z <span class="punctuation">===</span> undefined<span class="punctuation">)</span></span>
<span class="mark">z<span class="punctuation"> = </span><span class="literal">42</span></span><span class="semi">;</span>
<span class="keyword">return</span> x <span class="punctuation">+</span> y <span class="punctuation">+</span> z<span class="semi">;</span>
<span class="punctuation">}</span><span class="semi">;</span>
f<span class="punctuation">(</span><span class="literal">1</span><span class="punctuation">)</span> <span class="punctuation">===</span> <span class="literal">50</span><span class="semi">;</span></div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-times-circle"></i>
</div>
</div>
<div id="RestParameter" class="showcase showcase_RestParameter"> <div class="title">Extended Parameter Handling</div>
<div class="subtitle">Rest Parameter</div>
<div class="desc">Aggregation of remaining arguments into single parameter of variadic functions.</div>
<div class="js es6">
<div class="title"><b>ECMAScript 6</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code"><span class="keyword">function</span> f <span class="punctuation">(</span>x<span class="punctuation">,</span> y<span class="punctuation">,</span> <span class="mark"><span class="punctuation">.</span><span class="punctuation">.</span><span class="punctuation">.</span>a</span><span class="punctuation">)</span> <span class="punctuation">{</span>
<span class="keyword">return</span> <span class="punctuation">(</span>x <span class="punctuation">+</span> y<span class="punctuation">)</span> <span class="punctuation">*</span> a<span class="punctuation">.</span>length<span class="semi">;</span>
<span class="punctuation">}</span>
f<span class="punctuation">(</span><span class="literal">1</span><span class="punctuation">,</span> <span class="literal">2</span><span class="punctuation">,</span> <span class="mark"><span class="literal">"hello"</span><span class="punctuation">,</span> true<span class="punctuation">,</span> <span class="literal">7</span></span><span class="punctuation">)</span> <span class="punctuation">===</span> <span class="literal">9</span><span class="semi">;</span>
</div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-check-circle"></i>
</div>
<div class="arrow"><i class="fa fa-caret-up"></i><i class="fa fa-caret-down"></i></div><div class="js es5">
<div class="title"><b>ECMAScript 5</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code"><span class="keyword">function</span> f <span class="punctuation">(</span>x<span class="punctuation">,</span> y<span class="punctuation">)</span> <span class="punctuation">{</span>
<span class="mark"><span class="keyword">var</span> a<span class="punctuation"> = </span>Array<span class="punctuation">.</span>prototype<span class="punctuation">.</span>slice<span class="punctuation">.</span>call<span class="punctuation">(</span>arguments<span class="punctuation">,</span> <span class="literal">2</span><span class="punctuation">)</span></span><span class="semi">;</span>
<span class="keyword">return</span> <span class="punctuation">(</span>x <span class="punctuation">+</span> y<span class="punctuation">)</span> <span class="punctuation">*</span> a<span class="punctuation">.</span>length<span class="semi">;</span>
<span class="punctuation">}</span><span class="semi">;</span>
f<span class="punctuation">(</span><span class="literal">1</span><span class="punctuation">,</span> <span class="literal">2</span><span class="punctuation">,</span> <span class="mark"><span class="literal">"hello"</span><span class="punctuation">,</span> true<span class="punctuation">,</span> <span class="literal">7</span></span><span class="punctuation">)</span> <span class="punctuation">===</span> <span class="literal">9</span><span class="semi">;</span></div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-times-circle"></i>
</div>
</div>
<div id="SpreadOperator" class="showcase showcase_SpreadOperator"> <div class="title">Extended Parameter Handling</div>
<div class="subtitle">Spread Operator</div>
<div class="desc">Spreading of elements of an iterable collection (like an array or even
a string) into both literal elements and individual function parameters.</div>
<div class="js es6">
<div class="title"><b>ECMAScript 6</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code"><span class="keyword">var</span> params<span class="punctuation"> = </span><span class="punctuation">[</span> <span class="literal">"hello"</span><span class="punctuation">,</span> true<span class="punctuation">,</span> <span class="literal">7</span> <span class="punctuation">]</span><span class="semi">;</span>
<span class="keyword">var</span> other<span class="punctuation"> = </span><span class="punctuation">[</span> <span class="literal">1</span><span class="punctuation">,</span> <span class="literal">2</span><span class="punctuation">,</span> <span class="mark"><span class="punctuation">.</span><span class="punctuation">.</span><span class="punctuation">.</span>params</span> <span class="punctuation">]</span><span class="semi">;</span><span class="comment"> // <span class="punctuation">[</span> <span class="literal">1</span><span class="punctuation">,</span> <span class="literal">2</span><span class="punctuation">,</span> <span class="literal">"hello"</span><span class="punctuation">,</span> true<span class="punctuation">,</span> <span class="literal">7</span> <span class="punctuation">]</span></span>
<span class="keyword">function</span> f <span class="punctuation">(</span>x<span class="punctuation">,</span> y<span class="punctuation">,</span> <span class="punctuation">.</span><span class="punctuation">.</span><span class="punctuation">.</span>a<span class="punctuation">)</span> <span class="punctuation">{</span>
<span class="keyword">return</span> <span class="punctuation">(</span>x <span class="punctuation">+</span> y<span class="punctuation">)</span> <span class="punctuation">*</span> a<span class="punctuation">.</span>length<span class="semi">;</span>
<span class="punctuation">}</span>
f<span class="punctuation">(</span><span class="literal">1</span><span class="punctuation">,</span> <span class="literal">2</span><span class="punctuation">,</span> <span class="mark"><span class="punctuation">.</span><span class="punctuation">.</span><span class="punctuation">.</span>params</span><span class="punctuation">)</span> <span class="punctuation">===</span> <span class="literal">9</span><span class="semi">;</span>
<span class="keyword">var</span> str<span class="punctuation"> = </span><span class="literal">"foo"</span><span class="semi">;</span>
<span class="keyword">var</span> chars<span class="punctuation"> = </span><span class="punctuation">[</span> <span class="mark"><span class="punctuation">.</span><span class="punctuation">.</span><span class="punctuation">.</span>str</span> <span class="punctuation">]</span><span class="semi">;</span><span class="comment"> // <span class="punctuation">[</span> <span class="literal">"f"</span><span class="punctuation">,</span> <span class="literal">"o"</span><span class="punctuation">,</span> <span class="literal">"o"</span> <span class="punctuation">]</span></span>
</div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-check-circle"></i>
</div>
<div class="arrow"><i class="fa fa-caret-up"></i><i class="fa fa-caret-down"></i></div><div class="js es5">
<div class="title"><b>ECMAScript 5</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code"><span class="keyword">var</span> params<span class="punctuation"> = </span><span class="punctuation">[</span> <span class="literal">"hello"</span><span class="punctuation">,</span> true<span class="punctuation">,</span> <span class="literal">7</span> <span class="punctuation">]</span><span class="semi">;</span>
<span class="keyword">var</span> other<span class="punctuation"> = </span><span class="punctuation">[</span> <span class="literal">1</span><span class="punctuation">,</span> <span class="literal">2</span> <span class="punctuation">]</span><span class="punctuation">.</span><span class="mark">concat<span class="punctuation">(</span>params<span class="punctuation">)</span></span><span class="semi">;</span><span class="comment"> // <span class="punctuation">[</span> <span class="literal">1</span><span class="punctuation">,</span> <span class="literal">2</span><span class="punctuation">,</span> <span class="literal">"hello"</span><span class="punctuation">,</span> true<span class="punctuation">,</span> <span class="literal">7</span> <span class="punctuation">]</span></span>
<span class="keyword">function</span> f <span class="punctuation">(</span>x<span class="punctuation">,</span> y<span class="punctuation">)</span> <span class="punctuation">{</span>
<span class="keyword">var</span> a<span class="punctuation"> = </span>Array<span class="punctuation">.</span>prototype<span class="punctuation">.</span>slice<span class="punctuation">.</span>call<span class="punctuation">(</span>arguments<span class="punctuation">,</span> <span class="literal">2</span><span class="punctuation">)</span><span class="semi">;</span>
<span class="keyword">return</span> <span class="punctuation">(</span>x <span class="punctuation">+</span> y<span class="punctuation">)</span> <span class="punctuation">*</span> a<span class="punctuation">.</span>length<span class="semi">;</span>
<span class="punctuation">}</span><span class="semi">;</span>
f<span class="mark"><span class="punctuation">.</span>apply</span><span class="punctuation">(</span><span class="mark">undefined<span class="punctuation">,</span> <span class="punctuation">[</span></span> <span class="literal">1</span><span class="punctuation">,</span> <span class="literal">2</span> <span class="mark"><span class="punctuation">]</span><span class="punctuation">.</span>concat<span class="punctuation">(</span>params<span class="punctuation">)</span></span><span class="punctuation">)</span> <span class="punctuation">===</span> <span class="literal">9</span><span class="semi">;</span>
<span class="keyword">var</span> str<span class="punctuation"> = </span><span class="literal">"foo"</span><span class="semi">;</span>
<span class="keyword">var</span> chars<span class="punctuation"> = </span>str<span class="punctuation">.</span>split<span class="punctuation">(</span><span class="literal">""</span><span class="punctuation">)</span><span class="semi">;</span><span class="comment"> // <span class="punctuation">[</span> <span class="literal">"f"</span><span class="punctuation">,</span> <span class="literal">"o"</span><span class="punctuation">,</span> <span class="literal">"o"</span> <span class="punctuation">]</span></span></div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-times-circle"></i>
</div>
</div>
<div id="StringInterpolation" class="showcase showcase_StringInterpolation"> <div class="title">Template Literals</div>
<div class="subtitle">String Interpolation</div>
<div class="desc">Intuitive expression interpolation for single-line and multi-line strings.
(Notice: don't be confused, Template Literals were originally named
"Template Strings" in the drafts of the ECMAScript 6 language specification)</div>
<div class="js es6">
<div class="title"><b>ECMAScript 6</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code"><span class="keyword">var</span> customer<span class="punctuation"> = </span><span class="punctuation">{</span> name: <span class="literal">"Foo"</span> <span class="punctuation">}</span><span class="semi">;</span>
<span class="keyword">var</span> card<span class="punctuation"> = </span><span class="punctuation">{</span> amount: <span class="literal">7</span><span class="punctuation">,</span> product: <span class="literal">"Bar"</span><span class="punctuation">,</span> unitprice: <span class="literal">42</span> <span class="punctuation">}</span><span class="semi">;</span>
<span class="keyword">var</span> message<span class="punctuation"> = </span><span class="mark"><span class="literal">`</span>Hello <span class="mark">$<span class="punctuation">{</span>customer<span class="punctuation">.</span>name<span class="punctuation">}</span></span><span class="punctuation">,</span>
want to buy <span class="mark">$<span class="punctuation">{</span>card<span class="punctuation">.</span>amount<span class="punctuation">}</span> $<span class="punctuation">{</span>card<span class="punctuation">.</span>product<span class="punctuation">}</span></span> <span class="keyword">for</span>
a total <span class="keyword">of</span> <span class="mark">$<span class="punctuation">{</span>card<span class="punctuation">.</span>amount <span class="punctuation">*</span> card<span class="punctuation">.</span>unitprice<span class="punctuation">}</span></span> bucks?<span class="mark">`</span></span><span class="semi">;</span>
</div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-check-circle"></i>
</div>
<div class="arrow"><i class="fa fa-caret-up"></i><i class="fa fa-caret-down"></i></div><div class="js es5">
<div class="title"><b>ECMAScript 5</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code"><span class="keyword">var</span> customer<span class="punctuation"> = </span><span class="punctuation">{</span> name: <span class="literal">"Foo"</span> <span class="punctuation">}</span><span class="semi">;</span>
<span class="keyword">var</span> card<span class="punctuation"> = </span><span class="punctuation">{</span> amount: <span class="literal">7</span><span class="punctuation">,</span> product: <span class="literal">"Bar"</span><span class="punctuation">,</span> unitprice: <span class="literal">42</span> <span class="punctuation">}</span><span class="semi">;</span>
<span class="keyword">var</span> message<span class="punctuation"> = </span><span class="mark"><span class="literal">"</span>Hello "</span><span class="mark"> <span class="punctuation">+</span> customer<span class="punctuation">.</span>name <span class="punctuation">+</span> </span><span class="literal">"<span class="punctuation">,</span>\n"</span> <span class="punctuation">+</span>
<span class="literal">"want to buy "</span><span class="mark"> <span class="punctuation">+</span> card<span class="punctuation">.</span>amount <span class="punctuation">+</span> </span><span class="literal">" "</span><span class="mark"> <span class="punctuation">+</span> card<span class="punctuation">.</span>product <span class="punctuation">+</span> </span><span class="literal">" <span class="keyword">for</span>\n"</span> <span class="punctuation">+</span>
<span class="literal">"a total <span class="keyword">of</span> "</span><span class="mark"> <span class="punctuation">+</span> <span class="punctuation">(</span>card<span class="punctuation">.</span>amount <span class="punctuation">*</span> card<span class="punctuation">.</span>unitprice<span class="punctuation">)</span> <span class="punctuation">+</span> </span><span class="literal">" bucks?<span class="mark">"</span></span><span class="semi">;</span></div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-times-circle"></i>
</div>
</div>
<div id="CustomInterpolation" class="showcase showcase_CustomInterpolation"> <div class="title">Template Literals</div>
<div class="subtitle">Custom Interpolation</div>
<div class="desc">Flexible expression interpolation for arbitrary methods.</div>
<div class="js es6">
<div class="title"><b>ECMAScript 6</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code">get<span class="mark"><span class="literal">`</span>http://example<span class="punctuation">.</span>com/foo?bar=<span class="mark">$<span class="punctuation">{</span></span>bar <span class="punctuation">+</span> baz<span class="mark"><span class="punctuation">}</span></span><span class="punctuation"><span class="punctuation">&</span></span>quux=<span class="mark">$<span class="punctuation">{</span></span>quux<span class="mark"><span class="punctuation">}</span>`</span></span><span class="semi">;</span>
</div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-check-circle"></i>
</div>
<div class="arrow"><i class="fa fa-caret-up"></i><i class="fa fa-caret-down"></i></div><div class="js es5">
<div class="title"><b>ECMAScript 5</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code">get<span class="mark"><span class="punctuation">(</span><span class="punctuation">[</span> </span><span class="literal">"http://example<span class="punctuation">.</span>com/foo?bar="</span><span class="mark"><span class="punctuation">,</span></span> <span class="literal">"<span class="punctuation"><span class="punctuation">&</span></span>quux="</span><span class="mark"><span class="punctuation">,</span></span> <span class="literal">""</span><span class="mark"> <span class="punctuation">]</span><span class="punctuation">,</span></span>bar <span class="punctuation">+</span> baz<span class="mark"><span class="punctuation">,</span></span> quux<span class="mark"><span class="punctuation">)</span></span><span class="semi">;</span></div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-times-circle"></i>
</div>
</div>
<div id="RawStringAccess" class="showcase showcase_RawStringAccess"> <div class="title">Template Literals</div>
<div class="subtitle">Raw String Access</div>
<div class="desc">Access the raw template string content (backslashes are not interpreted).</div>
<div class="js es6">
<div class="title"><b>ECMAScript 6</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code"><span class="keyword">function</span> quux <span class="punctuation">(</span>strings<span class="punctuation">,</span> <span class="punctuation">.</span><span class="punctuation">.</span><span class="punctuation">.</span>values<span class="punctuation">)</span> <span class="punctuation">{</span>
strings<span class="punctuation">[</span><span class="literal">0</span><span class="punctuation">]</span> <span class="punctuation">===</span> <span class="literal">"<span class="mark">foo\n</span>"</span><span class="semi">;</span>
strings<span class="punctuation">[</span><span class="literal">1</span><span class="punctuation">]</span> <span class="punctuation">===</span> <span class="literal">"bar"</span><span class="semi">;</span>
strings<span class="mark"><span class="punctuation">.</span>raw</span><span class="punctuation">[</span><span class="literal">0</span><span class="punctuation">]</span> <span class="punctuation">===</span> <span class="literal">"<span class="mark">foo\\n</span>"</span><span class="semi">;</span>
strings<span class="punctuation">.</span>raw<span class="punctuation">[</span><span class="literal">1</span><span class="punctuation">]</span> <span class="punctuation">===</span> <span class="literal">"bar"</span><span class="semi">;</span>
values<span class="punctuation">[</span><span class="literal">0</span><span class="punctuation">]</span> <span class="punctuation">===</span> <span class="literal">42</span><span class="semi">;</span>
<span class="punctuation">}</span>
quux <span class="mark"><span class="literal">`</span>foo<span class="mark">\n</span>$<span class="punctuation">{</span> 42 <span class="punctuation">}</span>bar<span class="mark">`</span></span>
String<span class="punctuation">.</span>raw <span class="mark"><span class="literal">`</span>foo<span class="mark">\n</span>$<span class="punctuation">{</span> 42 <span class="punctuation">}</span>bar<span class="mark">`</span></span> <span class="punctuation">===</span> <span class="literal">"foo<span class="mark">\\n</span>42bar"</span><span class="semi">;</span>
</div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-check-circle"></i>
</div>
<div class="arrow"><i class="fa fa-caret-up"></i><i class="fa fa-caret-down"></i></div><div class="js es5">
<div class="title"><b>ECMAScript 5</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code"><span class="comment">// no equivalent <span class="keyword">in</span> ES<span class="literal">5</span></span></div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-times-circle"></i>
</div>
</div>
<div id="BinaryOctalLiteral" class="showcase showcase_BinaryOctalLiteral"> <div class="title">Extended Literals</div>
<div class="subtitle">Binary & Octal Literal</div>
<div class="desc">Direct support for safe binary and octal literals.</div>
<div class="js es6">
<div class="title"><b>ECMAScript 6</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code"><span class="mark"><span class="literal">0</span>b</span><span class="literal">111110111</span> <span class="punctuation">===</span> <span class="literal">503</span><span class="semi">;</span>
<span class="mark"><span class="literal">0</span>o</span><span class="literal">767</span> <span class="punctuation">===</span> <span class="literal">503</span><span class="semi">;</span>
</div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-check-circle"></i>
</div>
<div class="arrow"><i class="fa fa-caret-up"></i><i class="fa fa-caret-down"></i></div><div class="js es5">
<div class="title"><b>ECMAScript 5</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code"><span class="mark">parseInt<span class="punctuation">(</span></span><span class="literal">"111110111"</span><span class="mark"><span class="punctuation">,</span> <span class="literal">2</span><span class="punctuation">)</span></span> <span class="punctuation">===</span> <span class="literal">503</span><span class="semi">;</span>
<span class="mark">parseInt<span class="punctuation">(</span></span><span class="literal">"767"</span><span class="mark"><span class="punctuation">,</span> <span class="literal">8</span><span class="punctuation">)</span></span> <span class="punctuation">===</span> <span class="literal">503</span><span class="semi">;</span>
<span class="mark"><span class="literal">0</span></span><span class="literal">767</span> <span class="punctuation">===</span> <span class="literal">503</span><span class="semi">;</span><span class="comment"> // only <span class="keyword">in</span> non<span class="punctuation">-</span>strict<span class="punctuation">,</span> backward compatibility mode</span></div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-times-circle"></i>
</div>
</div>
<div id="UnicodeStringRegExpLiteral" class="showcase showcase_UnicodeStringRegExpLiteral"> <div class="title">Extended Literals</div>
<div class="subtitle">Unicode String & RegExp Literal</div>
<div class="desc">Extended support using Unicode within strings and regular expressions.</div>
<div class="js es6">
<div class="title"><b>ECMAScript 6</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code"><span class="literal">"𠮷"</span><span class="punctuation">.</span>length <span class="punctuation">===</span> <span class="literal">2</span><span class="semi">;</span>
<span class="literal">"𠮷"</span><span class="punctuation">.</span>match<span class="punctuation">(</span>/<span class="punctuation">.</span>/<span class="mark">u</span><span class="punctuation">)</span><span class="punctuation">[</span><span class="literal">0</span><span class="punctuation">]</span><span class="punctuation">.</span>length <span class="punctuation">===</span> <span class="literal">2</span><span class="semi">;</span>
<span class="literal">"𠮷"</span> <span class="punctuation">===</span> <span class="literal">"\uD842\uDFB7"</span><span class="semi">;</span>
<span class="literal">"𠮷"</span> <span class="punctuation">===</span> <span class="literal">"<span class="mark">\u<span class="punctuation">{</span>20BB7<span class="punctuation">}</span></span>"</span><span class="semi">;</span>
<span class="literal">"𠮷"</span><span class="punctuation">.</span><span class="mark">codePointAt</span><span class="punctuation">(</span><span class="literal">0</span><span class="punctuation">)</span> == <span class="literal">0</span>x<span class="literal">20</span>BB<span class="literal">7</span><span class="semi">;</span>
<span class="keyword">for</span> <span class="punctuation">(</span><span class="keyword">let</span> codepoint <span class="mark"><span class="keyword">of</span></span> <span class="literal">"𠮷"</span><span class="punctuation">)</span> console<span class="punctuation">.</span>log<span class="punctuation">(</span>codepoint<span class="punctuation">)</span><span class="semi">;</span>
</div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-check-circle"></i>
</div>
<div class="arrow"><i class="fa fa-caret-up"></i><i class="fa fa-caret-down"></i></div><div class="js es5">
<div class="title"><b>ECMAScript 5</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code"><span class="literal">"𠮷"</span><span class="punctuation">.</span>length <span class="punctuation">===</span> <span class="literal">2</span><span class="semi">;</span>
<span class="literal">"𠮷"</span><span class="punctuation">.</span>match<span class="punctuation">(</span>/<span class="punctuation">(</span>?:<span class="punctuation">[</span>\<span class="literal">0</span><span class="punctuation">-</span>\t\x<span class="literal">0</span>B\f\x<span class="literal">0</span>E<span class="punctuation">-</span>\u<span class="literal">2027</span>\u<span class="literal">202</span>A<span class="punctuation">-</span>\uD<span class="literal">7</span>FF\uE<span class="literal">000</span><span class="punctuation">-</span>\uFFFF<span class="punctuation">]</span><span class="mark"><span class="punctuation">[</span>\uD<span class="literal">800</span><span class="punctuation">-</span>\uDBFF<span class="punctuation">]</span><span class="punctuation">[</span>\uDC<span class="literal">00</span><span class="punctuation">-</span>\uDFFF<span class="punctuation">]</span></span><span class="punctuation">[</span>\uD<span class="literal">800</span><span class="punctuation">-</span>\uDBFF<span class="punctuation">]</span><span class="punctuation">(</span>?!<span class="punctuation">[</span>\uDC<span class="literal">00</span><span class="punctuation">-</span>\uDFFF<span class="punctuation">]</span><span class="punctuation">)</span><span class="mark"><span class="punctuation">(</span>?:<span class="punctuation">[</span>^\uD<span class="literal">800</span><span class="punctuation">-</span>\uDBFF<span class="punctuation">]</span></span>^<span class="punctuation">)</span><span class="punctuation">[</span>\uDC<span class="literal">00</span><span class="punctuation">-</span>\uDFFF<span class="punctuation">]</span><span class="punctuation">)</span>/<span class="punctuation">)</span><span class="punctuation">[</span><span class="literal">0</span><span class="punctuation">]</span><span class="punctuation">.</span>length <span class="punctuation">===</span> <span class="literal">2</span><span class="semi">;</span>
<span class="literal">"𠮷"</span> <span class="punctuation">===</span> <span class="literal">"\uD842\uDFB7"</span><span class="semi">;</span><span class="comment">
// no equivalent <span class="keyword">in</span> ES<span class="literal">5</span></span><span class="comment">
// no equivalent <span class="keyword">in</span> ES<span class="literal">5</span></span><span class="comment">
// no equivalent <span class="keyword">in</span> ES<span class="literal">5</span></span></div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-times-circle"></i>
</div>
</div>
<div id="RegularExpressionStickyMatching" class="showcase showcase_RegularExpressionStickyMatching"> <div class="title">Enhanced Regular Expression</div>
<div class="subtitle">Regular Expression Sticky Matching</div>
<div class="desc">Keep the matching position sticky between matches and
this way support efficient parsing of arbitrary long input strings,
even with an arbitrary number of distinct regular expressions.</div>
<div class="js es6">
<div class="title"><b>ECMAScript 6</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code"><span class="keyword">let</span> parser<span class="punctuation"> = </span><span class="punctuation">(</span>input<span class="punctuation">,</span> match<span class="punctuation">)</span> <span class="punctuation">=></span> <span class="punctuation">{</span>
<span class="keyword">for</span> <span class="punctuation">(</span><span class="keyword">let</span> pos<span class="punctuation"> = </span><span class="literal">0</span><span class="punctuation">,</span> lastPos<span class="punctuation"> = </span>input<span class="punctuation">.</span>length<span class="punctuation">;</span> <span class="mark">pos <span class="punctuation"><</span> lastPos</span><span class="punctuation">;</span> <span class="punctuation">)</span> <span class="punctuation">{</span>
<span class="keyword">for</span> <span class="punctuation">(</span><span class="keyword">let</span> i<span class="punctuation"> = </span><span class="literal">0</span><span class="punctuation">;</span> i <span class="punctuation"><</span> match<span class="punctuation">.</span>length<span class="punctuation">;</span> i<span class="punctuation">+</span><span class="punctuation">+</span><span class="punctuation">)</span> <span class="punctuation">{</span>
<span class="mark">match<span class="punctuation">[</span>i<span class="punctuation">]</span><span class="punctuation">.</span>pattern<span class="punctuation">.</span>lastIndex<span class="punctuation"> = </span>pos</span><span class="semi">;</span>
<span class="keyword">let</span> found<span class="semi">;</span>
<span class="keyword">if</span> <span class="punctuation">(</span><span class="punctuation">(</span>found<span class="punctuation"> = </span>match<span class="punctuation">[</span>i<span class="punctuation">]</span><span class="punctuation">.</span>pattern<span class="punctuation">.</span>exec<span class="punctuation">(</span>input<span class="punctuation">)</span><span class="punctuation">)</span> !== null<span class="punctuation">)</span> <span class="punctuation">{</span>
match<span class="punctuation">[</span>i<span class="punctuation">]</span><span class="punctuation">.</span>action<span class="punctuation">(</span>found<span class="punctuation">)</span><span class="semi">;</span>
<span class="mark">pos<span class="punctuation"> = </span>match<span class="punctuation">[</span>i<span class="punctuation">]</span><span class="punctuation">.</span>pattern<span class="punctuation">.</span>lastIndex</span><span class="semi">;</span>
break<span class="semi">;</span>
<span class="punctuation">}</span>
<span class="punctuation">}</span>
<span class="punctuation">}</span>
<span class="punctuation">}</span>
<span class="keyword">let</span> report<span class="punctuation"> = </span><span class="punctuation">(</span>match<span class="punctuation">)</span> <span class="punctuation">=></span> <span class="punctuation">{</span>
console<span class="punctuation">.</span>log<span class="punctuation">(</span>JSON<span class="punctuation">.</span>stringify<span class="punctuation">(</span>match<span class="punctuation">)</span><span class="punctuation">)</span><span class="semi">;</span>
<span class="punctuation">}</span><span class="semi">;</span>
parser<span class="punctuation">(</span><span class="literal">"Foo 1 Bar 7 Baz 42"</span><span class="punctuation">,</span> <span class="punctuation">[</span>
<span class="punctuation">{</span> pattern: /^Foo\s<span class="punctuation">+</span><span class="punctuation">(</span>\d<span class="punctuation">+</span><span class="punctuation">)</span>/<span class="mark">y</span><span class="punctuation">,</span> action: <span class="punctuation">(</span>match<span class="punctuation">)</span> <span class="punctuation">=></span> report<span class="punctuation">(</span>match<span class="punctuation">)</span> <span class="punctuation">}</span><span class="punctuation">,</span>
<span class="punctuation">{</span> pattern: /^Bar\s<span class="punctuation">+</span><span class="punctuation">(</span>\d<span class="punctuation">+</span><span class="punctuation">)</span>/<span class="mark">y</span><span class="punctuation">,</span> action: <span class="punctuation">(</span>match<span class="punctuation">)</span> <span class="punctuation">=></span> report<span class="punctuation">(</span>match<span class="punctuation">)</span> <span class="punctuation">}</span><span class="punctuation">,</span>
<span class="punctuation">{</span> pattern: /^Baz\s<span class="punctuation">+</span><span class="punctuation">(</span>\d<span class="punctuation">+</span><span class="punctuation">)</span>/<span class="mark">y</span><span class="punctuation">,</span> action: <span class="punctuation">(</span>match<span class="punctuation">)</span> <span class="punctuation">=></span> report<span class="punctuation">(</span>match<span class="punctuation">)</span> <span class="punctuation">}</span><span class="punctuation">,</span>
<span class="punctuation">{</span> pattern: /^\s<span class="punctuation">*</span>/<span class="mark">y</span><span class="punctuation">,</span> action: <span class="punctuation">(</span>match<span class="punctuation">)</span> <span class="punctuation">=></span> <span class="punctuation">{</span><span class="punctuation">}</span> <span class="punctuation">}</span>
<span class="punctuation">]</span><span class="punctuation">)</span><span class="semi">;</span>
</div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-check-circle"></i>
</div>
<div class="arrow"><i class="fa fa-caret-up"></i><i class="fa fa-caret-down"></i></div><div class="js es5">
<div class="title"><b>ECMAScript 5</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code"><span class="keyword">var</span> parser<span class="punctuation"> = </span><span class="keyword">function</span> <span class="punctuation">(</span>input<span class="punctuation">,</span> match<span class="punctuation">)</span> <span class="punctuation">{</span>
<span class="keyword">for</span> <span class="punctuation">(</span><span class="keyword">var</span> i<span class="punctuation">,</span> found<span class="punctuation">,</span> <span class="mark">inputTmp<span class="punctuation"> = </span>input</span><span class="punctuation">;</span> <span class="mark">inputTmp !== <span class="literal">""</span></span><span class="punctuation">;</span> <span class="punctuation">)</span> <span class="punctuation">{</span>
<span class="keyword">for</span> <span class="punctuation">(</span>i<span class="punctuation"> = </span><span class="literal">0</span><span class="punctuation">;</span> i <span class="punctuation"><</span> match<span class="punctuation">.</span>length<span class="punctuation">;</span> i<span class="punctuation">+</span><span class="punctuation">+</span><span class="punctuation">)</span> <span class="punctuation">{</span>
<span class="keyword">if</span> <span class="punctuation">(</span><span class="punctuation">(</span>found<span class="punctuation"> = </span>match<span class="punctuation">[</span>i<span class="punctuation">]</span><span class="punctuation">.</span>pattern<span class="punctuation">.</span>exec<span class="punctuation">(</span>inputTmp<span class="punctuation">)</span><span class="punctuation">)</span> !== null<span class="punctuation">)</span> <span class="punctuation">{</span>
match<span class="punctuation">[</span>i<span class="punctuation">]</span><span class="punctuation">.</span>action<span class="punctuation">(</span>found<span class="punctuation">)</span><span class="semi">;</span>
<span class="mark">inputTmp<span class="punctuation"> = </span>inputTmp<span class="punctuation">.</span>substr<span class="punctuation">(</span>found<span class="punctuation">[</span><span class="literal">0</span><span class="punctuation">]</span><span class="punctuation">.</span>length<span class="punctuation">)</span></span><span class="semi">;</span>
break<span class="semi">;</span>
<span class="punctuation">}</span>
<span class="punctuation">}</span>
<span class="punctuation">}</span>
<span class="punctuation">}</span>
<span class="keyword">var</span> report<span class="punctuation"> = </span><span class="keyword">function</span> <span class="punctuation">(</span>match<span class="punctuation">)</span> <span class="punctuation">{</span>
console<span class="punctuation">.</span>log<span class="punctuation">(</span>JSON<span class="punctuation">.</span>stringify<span class="punctuation">(</span>match<span class="punctuation">)</span><span class="punctuation">)</span><span class="semi">;</span>
<span class="punctuation">}</span><span class="semi">;</span>
parser<span class="punctuation">(</span><span class="literal">"Foo 1 Bar 7 Baz 42"</span><span class="punctuation">,</span> <span class="punctuation">[</span>
<span class="punctuation">{</span> pattern: /^Foo\s<span class="punctuation">+</span><span class="punctuation">(</span>\d<span class="punctuation">+</span><span class="punctuation">)</span>/<span class="punctuation">,</span> action: <span class="keyword">function</span> <span class="punctuation">(</span>match<span class="punctuation">)</span> <span class="punctuation">{</span> report<span class="punctuation">(</span>match<span class="punctuation">)</span><span class="semi">;</span> <span class="punctuation">}</span> <span class="punctuation">}</span><span class="punctuation">,</span>
<span class="punctuation">{</span> pattern: /^Bar\s<span class="punctuation">+</span><span class="punctuation">(</span>\d<span class="punctuation">+</span><span class="punctuation">)</span>/<span class="punctuation">,</span> action: <span class="keyword">function</span> <span class="punctuation">(</span>match<span class="punctuation">)</span> <span class="punctuation">{</span> report<span class="punctuation">(</span>match<span class="punctuation">)</span><span class="semi">;</span> <span class="punctuation">}</span> <span class="punctuation">}</span><span class="punctuation">,</span>
<span class="punctuation">{</span> pattern: /^Baz\s<span class="punctuation">+</span><span class="punctuation">(</span>\d<span class="punctuation">+</span><span class="punctuation">)</span>/<span class="punctuation">,</span> action: <span class="keyword">function</span> <span class="punctuation">(</span>match<span class="punctuation">)</span> <span class="punctuation">{</span> report<span class="punctuation">(</span>match<span class="punctuation">)</span><span class="semi">;</span> <span class="punctuation">}</span> <span class="punctuation">}</span><span class="punctuation">,</span>
<span class="punctuation">{</span> pattern: /^\s<span class="punctuation">*</span>/<span class="punctuation">,</span> action: <span class="keyword">function</span> <span class="punctuation">(</span>match<span class="punctuation">)</span> <span class="punctuation">{</span><span class="punctuation">}</span> <span class="punctuation">}</span>
<span class="punctuation">]</span><span class="punctuation">)</span><span class="semi">;</span></div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-times-circle"></i>
</div>
</div>
<div id="PropertyShorthand" class="showcase showcase_PropertyShorthand"> <div class="title">Enhanced Object Properties</div>
<div class="subtitle">Property Shorthand</div>
<div class="desc">Shorter syntax for common object property definition idiom.</div>
<div class="js es6">
<div class="title"><b>ECMAScript 6</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code">obj<span class="punctuation"> = </span><span class="punctuation">{</span> <span class="mark">x</span><span class="punctuation">,</span> <span class="mark">y</span> <span class="punctuation">}</span><span class="semi">;</span>
</div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-check-circle"></i>
</div>
<div class="arrow"><i class="fa fa-caret-up"></i><i class="fa fa-caret-down"></i></div><div class="js es5">
<div class="title"><b>ECMAScript 5</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code">obj<span class="punctuation"> = </span><span class="punctuation">{</span> <span class="mark">x: x</span><span class="punctuation">,</span> <span class="mark">y: y</span> <span class="punctuation">}</span><span class="semi">;</span></div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-times-circle"></i>
</div>
</div>
<div id="ComputedPropertyNames" class="showcase showcase_ComputedPropertyNames"> <div class="title">Enhanced Object Properties</div>
<div class="subtitle">Computed Property Names</div>
<div class="desc">Support for computed names in object property definitions.</div>
<div class="js es6">
<div class="title"><b>ECMAScript 6</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code"><span class="keyword">let</span> obj<span class="punctuation"> = </span><span class="punctuation">{</span>
foo: <span class="literal">"bar"</span><span class="punctuation">,</span>
<span class="mark"><span class="punctuation">[</span></span> <span class="literal">"baz"</span> <span class="punctuation">+</span> quux<span class="punctuation">(</span><span class="punctuation">)</span> <span class="mark"><span class="punctuation">]</span>:</span> <span class="literal">42</span>
<span class="punctuation">}</span><span class="semi">;</span>
</div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-check-circle"></i>
</div>
<div class="arrow"><i class="fa fa-caret-up"></i><i class="fa fa-caret-down"></i></div><div class="js es5">
<div class="title"><b>ECMAScript 5</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code"><span class="keyword">var</span> obj<span class="punctuation"> = </span><span class="punctuation">{</span>
foo: <span class="literal">"bar"</span>
<span class="punctuation">}</span><span class="semi">;</span>
<span class="mark">obj<span class="punctuation">[</span></span> <span class="literal">"baz"</span> <span class="punctuation">+</span> quux<span class="punctuation">(</span><span class="punctuation">)</span> <span class="mark"><span class="punctuation">]</span> =</span> <span class="literal">42</span><span class="semi">;</span></div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-times-circle"></i>
</div>
</div>
<div id="MethodProperties" class="showcase showcase_MethodProperties"> <div class="title">Enhanced Object Properties</div>
<div class="subtitle">Method Properties</div>
<div class="desc">Support for method notation in object property definitions,
for both regular functions and generator functions.</div>
<div class="js es6">
<div class="title"><b>ECMAScript 6</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code">obj<span class="punctuation"> = </span><span class="punctuation">{</span>
<span class="mark">foo <span class="punctuation">(</span>a<span class="punctuation">,</span> b<span class="punctuation">)</span></span> <span class="punctuation">{</span>
<span class="ellipsis">…</span>
<span class="punctuation">}</span><span class="punctuation">,</span>
<span class="mark">bar <span class="punctuation">(</span>x<span class="punctuation">,</span> y<span class="punctuation">)</span></span> <span class="punctuation">{</span>
<span class="ellipsis">…</span>
<span class="punctuation">}</span><span class="punctuation">,</span>
<span class="mark"><span class="punctuation">*</span>quux <span class="punctuation">(</span>x<span class="punctuation">,</span> y<span class="punctuation">)</span></span> <span class="punctuation">{</span>
<span class="ellipsis">…</span>
<span class="punctuation">}</span>
<span class="punctuation">}</span><span class="semi">;</span>
</div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-check-circle"></i>
</div>
<div class="arrow"><i class="fa fa-caret-up"></i><i class="fa fa-caret-down"></i></div><div class="js es5">
<div class="title"><b>ECMAScript 5</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code">obj<span class="punctuation"> = </span><span class="punctuation">{</span>
foo<span class="mark">: <span class="keyword">function</span></span> <span class="punctuation">(</span>a<span class="punctuation">,</span> b<span class="punctuation">)</span> <span class="punctuation">{</span>
<span class="ellipsis">…</span>
<span class="punctuation">}</span><span class="punctuation">,</span>
bar<span class="mark">: <span class="keyword">function</span></span> <span class="punctuation">(</span>x<span class="punctuation">,</span> y<span class="punctuation">)</span> <span class="punctuation">{</span>
<span class="ellipsis">…</span>
<span class="punctuation">}</span><span class="punctuation">,</span>
<span class="comment"> // quux: no equivalent <span class="keyword">in</span> ES<span class="literal">5</span></span>
<span class="ellipsis">…</span>
<span class="punctuation">}</span><span class="semi">;</span></div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-times-circle"></i>
</div>
</div>
<div id="ArrayMatching" class="showcase showcase_ArrayMatching"> <div class="title">Destructuring Assignment</div>
<div class="subtitle">Array Matching</div>
<div class="desc">Intuitive and flexible destructuring of Arrays into individual variables during assignment.</div>
<div class="js es6">
<div class="title"><b>ECMAScript 6</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code"><span class="keyword">var</span> list<span class="punctuation"> = </span><span class="punctuation">[</span> <span class="literal">1</span><span class="punctuation">,</span> <span class="literal">2</span><span class="punctuation">,</span> <span class="literal">3</span> <span class="punctuation">]</span><span class="semi">;</span>
<span class="keyword">var</span> <span class="mark"><span class="punctuation">[</span> a<span class="punctuation">,</span> <span class="punctuation">,</span> b <span class="punctuation">]</span><span class="punctuation"> = </span>list</span><span class="semi">;</span>
<span class="punctuation">[</span> <span class="mark">b<span class="punctuation">,</span> a</span> <span class="punctuation">]</span><span class="punctuation"> = </span><span class="punctuation">[</span> <span class="mark">a<span class="punctuation">,</span> b</span> <span class="punctuation">]</span><span class="semi">;</span>
</div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-check-circle"></i>
</div>
<div class="arrow"><i class="fa fa-caret-up"></i><i class="fa fa-caret-down"></i></div><div class="js es5">
<div class="title"><b>ECMAScript 5</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code"><span class="keyword">var</span> list<span class="punctuation"> = </span><span class="punctuation">[</span> <span class="literal">1</span><span class="punctuation">,</span> <span class="literal">2</span><span class="punctuation">,</span> <span class="literal">3</span> <span class="punctuation">]</span><span class="semi">;</span>
<span class="keyword">var</span> <span class="mark">a<span class="punctuation"> = </span>list<span class="punctuation">[</span><span class="literal">0</span><span class="punctuation">]</span></span><span class="punctuation">,</span> <span class="mark">b<span class="punctuation"> = </span>list<span class="punctuation">[</span><span class="literal">2</span><span class="punctuation">]</span></span><span class="semi">;</span>
<span class="keyword">var</span> <span class="mark">tmp<span class="punctuation"> = </span>a</span><span class="punctuation">;</span> <span class="mark">a<span class="punctuation"> = </span>b</span><span class="punctuation">;</span> <span class="mark">b<span class="punctuation"> = </span>tmp</span><span class="semi">;</span></div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-times-circle"></i>
</div>
</div>
<div id="ObjectMatchingShorthandNotation" class="showcase showcase_ObjectMatchingShorthandNotation"> <div class="title">Destructuring Assignment</div>
<div class="subtitle">Object Matching, Shorthand Notation</div>
<div class="desc">Intuitive and flexible destructuring of Objects into individual variables during assignment.</div>
<div class="js es6">
<div class="title"><b>ECMAScript 6</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code"><span class="keyword">var</span> <span class="mark"><span class="punctuation">{</span> op<span class="punctuation">,</span> lhs<span class="punctuation">,</span> rhs <span class="punctuation">}</span></span><span class="punctuation"> = </span>getASTNode<span class="punctuation">(</span><span class="punctuation">)</span><span class="semi">;</span>
</div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-check-circle"></i>
</div>
<div class="arrow"><i class="fa fa-caret-up"></i><i class="fa fa-caret-down"></i></div><div class="js es5">
<div class="title"><b>ECMAScript 5</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code"><span class="keyword">var</span> <span class="mark">tmp</span><span class="punctuation"> = </span>getASTNode<span class="punctuation">(</span><span class="punctuation">)</span><span class="semi">;</span>
<span class="keyword">var</span> <span class="mark">op <span class="punctuation"> = </span>tmp<span class="punctuation">.</span>op</span><span class="semi">;</span>
<span class="keyword">var</span> <span class="mark">lhs<span class="punctuation"> = </span>tmp<span class="punctuation">.</span>lhs</span><span class="semi">;</span>
<span class="keyword">var</span> <span class="mark">rhs<span class="punctuation"> = </span>tmp<span class="punctuation">.</span>rhs</span><span class="semi">;</span></div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-times-circle"></i>
</div>
</div>
<div id="ObjectMatchingDeepMatching" class="showcase showcase_ObjectMatchingDeepMatching"> <div class="title">Destructuring Assignment</div>
<div class="subtitle">Object Matching, Deep Matching</div>
<div class="desc">Intuitive and flexible destructuring of Objects into individual variables during assignment.</div>
<div class="js es6">
<div class="title"><b>ECMAScript 6</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code"><span class="keyword">var</span> <span class="punctuation">{</span> op: a<span class="punctuation">,</span> <span class="mark">lhs: <span class="punctuation">{</span> op: b <span class="punctuation">}</span></span><span class="punctuation">,</span> rhs: c <span class="punctuation">}</span><span class="punctuation"> = </span>getASTNode<span class="punctuation">(</span><span class="punctuation">)</span><span class="semi">;</span>
</div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-check-circle"></i>
</div>
<div class="arrow"><i class="fa fa-caret-up"></i><i class="fa fa-caret-down"></i></div><div class="js es5">
<div class="title"><b>ECMAScript 5</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code"><span class="keyword">var</span> tmp<span class="punctuation"> = </span>getASTNode<span class="punctuation">(</span><span class="punctuation">)</span><span class="semi">;</span>
<span class="keyword">var</span> a<span class="punctuation"> = </span>tmp<span class="punctuation">.</span>op<span class="semi">;</span>
<span class="keyword">var</span> <span class="mark">b<span class="punctuation"> = </span>tmp<span class="punctuation">.</span>lhs<span class="punctuation">.</span>op</span><span class="semi">;</span>
<span class="keyword">var</span> c<span class="punctuation"> = </span>tmp<span class="punctuation">.</span>rhs<span class="semi">;</span></div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-times-circle"></i>
</div>
</div>
<div id="ObjectAndArrayMatchingDefaultValues" class="showcase showcase_ObjectAndArrayMatchingDefaultValues"> <div class="title">Destructuring Assignment</div>
<div class="subtitle">Object And Array Matching, Default Values</div>
<div class="desc">Simple and intuitive default values for destructuring of Objects and Arrays.</div>
<div class="js es6">
<div class="title"><b>ECMAScript 6</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code"><span class="keyword">var</span> obj<span class="punctuation"> = </span><span class="punctuation">{</span> a: <span class="literal">1</span> <span class="punctuation">}</span><span class="semi">;</span>
<span class="keyword">var</span> list<span class="punctuation"> = </span><span class="punctuation">[</span> <span class="literal">1</span> <span class="punctuation">]</span><span class="semi">;</span>
<span class="keyword">var</span> <span class="punctuation">{</span> a<span class="punctuation">,</span> <span class="mark">b<span class="punctuation"> = </span><span class="literal">2</span></span> <span class="punctuation">}</span><span class="punctuation"> = </span>obj<span class="semi">;</span>
<span class="keyword">var</span> <span class="punctuation">[</span> x<span class="punctuation">,</span> <span class="mark">y<span class="punctuation"> = </span><span class="literal">2</span></span> <span class="punctuation">]</span><span class="punctuation"> = </span>list<span class="semi">;</span>
</div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-check-circle"></i>
</div>
<div class="arrow"><i class="fa fa-caret-up"></i><i class="fa fa-caret-down"></i></div><div class="js es5">
<div class="title"><b>ECMAScript 5</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code"><span class="keyword">var</span> obj<span class="punctuation"> = </span><span class="punctuation">{</span> a: <span class="literal">1</span> <span class="punctuation">}</span><span class="semi">;</span>
<span class="keyword">var</span> list<span class="punctuation"> = </span><span class="punctuation">[</span> <span class="literal">1</span> <span class="punctuation">]</span><span class="semi">;</span>
<span class="keyword">var</span> a<span class="punctuation"> = </span>obj<span class="punctuation">.</span>a<span class="semi">;</span>
<span class="keyword">var</span> <span class="mark">b<span class="punctuation"> = </span>obj<span class="punctuation">.</span>b <span class="punctuation">===</span> undefined ? <span class="literal">2</span> : obj<span class="punctuation">.</span>b</span><span class="semi">;</span>
<span class="keyword">var</span> x<span class="punctuation"> = </span>list<span class="punctuation">[</span><span class="literal">0</span><span class="punctuation">]</span><span class="semi">;</span>
<span class="keyword">var</span> <span class="mark">y<span class="punctuation"> = </span>list<span class="punctuation">[</span><span class="literal">1</span><span class="punctuation">]</span> <span class="punctuation">===</span> undefined ? <span class="literal">2</span> : list<span class="punctuation">[</span><span class="literal">1</span><span class="punctuation">]</span></span><span class="semi">;</span></div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-times-circle"></i>
</div>
</div>
<div id="ParameterContextMatching" class="showcase showcase_ParameterContextMatching"> <div class="title">Destructuring Assignment</div>
<div class="subtitle">Parameter Context Matching</div>
<div class="desc">Intuitive and flexible destructuring of Arrays and Objects into individual parameters during function calls.</div>
<div class="js es6">
<div class="title"><b>ECMAScript 6</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code"><span class="keyword">function</span> f <span class="punctuation">(</span><span class="mark"><span class="punctuation">[</span> name<span class="punctuation">,</span> val <span class="punctuation">]</span></span><span class="punctuation">)</span> <span class="punctuation">{</span>
console<span class="punctuation">.</span>log<span class="punctuation">(</span>name<span class="punctuation">,</span> val<span class="punctuation">)</span><span class="semi">;</span>
<span class="punctuation">}</span>
<span class="keyword">function</span> g <span class="punctuation">(</span><span class="mark"><span class="punctuation">{</span> name: n<span class="punctuation">,</span> val: v <span class="punctuation">}</span></span><span class="punctuation">)</span> <span class="punctuation">{</span>
console<span class="punctuation">.</span>log<span class="punctuation">(</span>n<span class="punctuation">,</span> v<span class="punctuation">)</span><span class="semi">;</span>
<span class="punctuation">}</span>
<span class="keyword">function</span> h <span class="punctuation">(</span><span class="mark"><span class="punctuation">{</span> name<span class="punctuation">,</span> val <span class="punctuation">}</span></span><span class="punctuation">)</span> <span class="punctuation">{</span>
console<span class="punctuation">.</span>log<span class="punctuation">(</span>name<span class="punctuation">,</span> val<span class="punctuation">)</span><span class="semi">;</span>
<span class="punctuation">}</span>
f<span class="punctuation">(</span><span class="punctuation">[</span> <span class="literal">"bar"</span><span class="punctuation">,</span> <span class="literal">42</span> <span class="punctuation">]</span><span class="punctuation">)</span><span class="semi">;</span>
g<span class="punctuation">(</span><span class="punctuation">{</span> name: <span class="literal">"foo"</span><span class="punctuation">,</span> val: <span class="literal">7</span> <span class="punctuation">}</span><span class="punctuation">)</span><span class="semi">;</span>
h<span class="punctuation">(</span><span class="punctuation">{</span> name: <span class="literal">"bar"</span><span class="punctuation">,</span> val: <span class="literal">42</span> <span class="punctuation">}</span><span class="punctuation">)</span><span class="semi">;</span>
</div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-check-circle"></i>
</div>
<div class="arrow"><i class="fa fa-caret-up"></i><i class="fa fa-caret-down"></i></div><div class="js es5">
<div class="title"><b>ECMAScript 5</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code"><span class="keyword">function</span> f <span class="punctuation">(</span><span class="mark">arg</span><span class="punctuation">)</span> <span class="punctuation">{</span>
<span class="mark"><span class="keyword">var</span> name<span class="punctuation"> = </span>arg<span class="punctuation">[</span><span class="literal">0</span><span class="punctuation">]</span></span><span class="semi">;</span>
<span class="mark"><span class="keyword">var</span> val <span class="punctuation"> = </span>arg<span class="punctuation">[</span><span class="literal">1</span><span class="punctuation">]</span></span><span class="semi">;</span>
console<span class="punctuation">.</span>log<span class="punctuation">(</span>name<span class="punctuation">,</span> val<span class="punctuation">)</span><span class="semi">;</span>
<span class="punctuation">}</span><span class="semi">;</span>
<span class="keyword">function</span> g <span class="punctuation">(</span><span class="mark">arg</span><span class="punctuation">)</span> <span class="punctuation">{</span>
<span class="mark"><span class="keyword">var</span> n<span class="punctuation"> = </span>arg<span class="punctuation">.</span>name</span><span class="semi">;</span>
<span class="mark"><span class="keyword">var</span> v<span class="punctuation"> = </span>arg<span class="punctuation">.</span>val</span><span class="semi">;</span>
console<span class="punctuation">.</span>log<span class="punctuation">(</span>n<span class="punctuation">,</span> v<span class="punctuation">)</span><span class="semi">;</span>
<span class="punctuation">}</span><span class="semi">;</span>
<span class="keyword">function</span> h <span class="punctuation">(</span><span class="mark">arg</span><span class="punctuation">)</span> <span class="punctuation">{</span>
<span class="mark"><span class="keyword">var</span> name<span class="punctuation"> = </span>arg<span class="punctuation">.</span>name</span><span class="semi">;</span>
<span class="mark"><span class="keyword">var</span> val <span class="punctuation"> = </span>arg<span class="punctuation">.</span>val</span><span class="semi">;</span>
console<span class="punctuation">.</span>log<span class="punctuation">(</span>name<span class="punctuation">,</span> val<span class="punctuation">)</span><span class="semi">;</span>
<span class="punctuation">}</span><span class="semi">;</span>
f<span class="punctuation">(</span><span class="punctuation">[</span> <span class="literal">"bar"</span><span class="punctuation">,</span> <span class="literal">42</span> <span class="punctuation">]</span><span class="punctuation">)</span><span class="semi">;</span>
g<span class="punctuation">(</span><span class="punctuation">{</span> name: <span class="literal">"foo"</span><span class="punctuation">,</span> val: <span class="literal">7</span> <span class="punctuation">}</span><span class="punctuation">)</span><span class="semi">;</span>
h<span class="punctuation">(</span><span class="punctuation">{</span> name: <span class="literal">"bar"</span><span class="punctuation">,</span> val: <span class="literal">42</span> <span class="punctuation">}</span><span class="punctuation">)</span><span class="semi">;</span></div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-times-circle"></i>
</div>
</div>
<div id="FailSoftDestructuring" class="showcase showcase_FailSoftDestructuring"> <div class="title">Destructuring Assignment</div>
<div class="subtitle">Fail-Soft Destructuring</div>
<div class="desc">Fail-soft destructuring, optionally with defaults.</div>
<div class="js es6">
<div class="title"><b>ECMAScript 6</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code"><span class="keyword">var</span> list<span class="punctuation"> = </span><span class="punctuation">[</span> <span class="literal">7</span><span class="punctuation">,</span> <span class="literal">42</span> <span class="punctuation">]</span><span class="semi">;</span>
<span class="keyword">var</span> <span class="punctuation">[</span> a<span class="punctuation"> = </span><span class="literal">1</span><span class="punctuation">,</span> b<span class="punctuation"> = </span><span class="literal">2</span><span class="punctuation">,</span> <span class="mark">c<span class="punctuation"> = </span><span class="literal">3</span></span><span class="punctuation">,</span> <span class="mark">d</span> <span class="punctuation">]</span><span class="punctuation"> = </span>list<span class="semi">;</span>
a <span class="punctuation">===</span> <span class="literal">7</span><span class="semi">;</span>
b <span class="punctuation">===</span> <span class="literal">42</span><span class="semi">;</span>
c <span class="punctuation">===</span> <span class="mark"><span class="literal">3</span></span><span class="semi">;</span>
d <span class="punctuation">===</span> <span class="mark">undefined</span><span class="semi">;</span>
</div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-check-circle"></i>
</div>
<div class="arrow"><i class="fa fa-caret-up"></i><i class="fa fa-caret-down"></i></div><div class="js es5">
<div class="title"><b>ECMAScript 5</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code"><span class="keyword">var</span> list<span class="punctuation"> = </span><span class="punctuation">[</span> <span class="literal">7</span><span class="punctuation">,</span> <span class="literal">42</span> <span class="punctuation">]</span><span class="semi">;</span>
<span class="keyword">var</span> a<span class="punctuation"> = </span>typeof list<span class="punctuation">[</span><span class="literal">0</span><span class="punctuation">]</span> !== <span class="literal">"undefined"</span> ? list<span class="punctuation">[</span><span class="literal">0</span><span class="punctuation">]</span> : <span class="literal">1</span><span class="semi">;</span>
<span class="keyword">var</span> b<span class="punctuation"> = </span>typeof list<span class="punctuation">[</span><span class="literal">1</span><span class="punctuation">]</span> !== <span class="literal">"undefined"</span> ? list<span class="punctuation">[</span><span class="literal">1</span><span class="punctuation">]</span> : <span class="literal">2</span><span class="semi">;</span>
<span class="keyword">var</span> c<span class="punctuation"> = </span>typeof list<span class="punctuation">[</span><span class="literal">2</span><span class="punctuation">]</span> !== <span class="literal">"undefined"</span> ? list<span class="punctuation">[</span><span class="literal">2</span><span class="punctuation">]</span> : <span class="mark"><span class="literal">3</span></span><span class="semi">;</span>
<span class="keyword">var</span> d<span class="punctuation"> = </span>typeof list<span class="punctuation">[</span><span class="literal">3</span><span class="punctuation">]</span> !== <span class="literal">"undefined"</span> ? list<span class="punctuation">[</span><span class="literal">3</span><span class="punctuation">]</span> : <span class="mark">undefined</span><span class="semi">;</span>
a <span class="punctuation">===</span> <span class="literal">7</span><span class="semi">;</span>
b <span class="punctuation">===</span> <span class="literal">42</span><span class="semi">;</span>
c <span class="punctuation">===</span> <span class="mark"><span class="literal">3</span></span><span class="semi">;</span>
d <span class="punctuation">===</span> <span class="mark">undefined</span><span class="semi">;</span></div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-times-circle"></i>
</div>
</div>
<div id="ValueExportImport" class="showcase showcase_ValueExportImport"> <div class="title">Modules</div>
<div class="subtitle">Value Export/Import</div>
<div class="desc">Support for exporting/importing values from/to modules without global namespace pollution.</div>
<div class="js es6">
<div class="title"><b>ECMAScript 6</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>
<div class="code"><span class="comment">// lib/math<span class="punctuation">.</span>js</span>
<span class="mark"><span class="keyword">export</span></span> <span class="keyword">function</span> <span class="mark">sum</span> <span class="punctuation">(</span>x<span class="punctuation">,</span> y<span class="punctuation">)</span> <span class="punctuation">{</span> <span class="keyword">return</span> x <span class="punctuation">+</span> y <span class="punctuation">}</span><span class="semi">;</span>
<span class="mark"><span class="keyword">export</span></span> <span class="keyword">var</span> <span class="mark">pi</span><span class="punctuation"> = </span><span class="literal">3</span><span class="punctuation">.</span><span class="literal">141593</span><span class="semi">;</span>
<span class="comment">
// someApp<span class="punctuation">.</span>js</span>
<span class="mark"><span class="keyword">import</span> <span class="punctuation">*</span> as math</span> from <span class="literal">"lib/math"</span><span class="semi">;</span>
console<span class="punctuation">.</span>log<span class="punctuation">(</span><span class="literal">"2π<span class="punctuation"> = </span>"</span> <span class="punctuation">+</span> math<span class="punctuation">.</span>sum<span class="punctuation">(</span>math<span class="punctuation">.</span>pi<span class="punctuation">,</span> math<span class="punctuation">.</span>pi<span class="punctuation">)</span><span class="punctuation">)</span><span class="semi">;</span>
<span class="comment">
// otherApp<span class="punctuation">.</span>js</span>
<span class="mark"><span class="keyword">import</span> <span class="punctuation">{</span> sum<span class="punctuation">,</span> pi <span class="punctuation">}</span></span> from <span class="literal">"lib/math"</span><span class="semi">;</span>
console<span class="punctuation">.</span>log<span class="punctuation">(</span><span class="literal">"2π<span class="punctuation"> = </span>"</span> <span class="punctuation">+</span> sum<span class="punctuation">(</span>pi<span class="punctuation">,</span> pi<span class="punctuation">)</span><span class="punctuation">)</span><span class="semi">;</span>
</div>
<i class="icon fa fa-circle"></i>
<i class="icon fa fa-check-circle"></i>
</div>
<div class="arrow"><i class="fa fa-caret-up"></i><i class="fa fa-caret-down"></i></div><div class="js es5">
<div class="title"><b>ECMAScript 5</b> — syntactic sugar: <span class="style reduced">reduced</span> | <span class="style traditional">traditional</span></div>