File: index.html

package info (click to toggle)
coffeescript 1.10.0~dfsg-1~bpo8+1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 3,292 kB
  • sloc: makefile: 62
file content (3695 lines) | stat: -rw-r--r-- 181,899 bytes parent folder | download | duplicates (2)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
  <title>CoffeeScript</title>
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <link rel="canonical" href="http://coffeescript.org" />
  <link rel="stylesheet" type="text/css" href="documentation/css/docs.css" />
  <link rel="stylesheet" type="text/css" href="documentation/css/tomorrow.css" />
  <link rel="shortcut icon" href="documentation/images/favicon.ico" />
</head>
<body>

  <div id="fadeout"></div>

  <div id="flybar">
    <a id="logo" href="#top"><img src="documentation/images/logo.png" width="225" height="39" alt="CoffeeScript" /></a>
    <div class="navigation toc">
      <div class="button">
        Table of Contents
      </div>
      <div class="contents menu">
        <a href="#overview">Overview</a>
        <a href="#installation">Installation</a>
        <a href="#usage">Usage</a>
        <a href="#literate">Literate CoffeeScript</a>
        <a href="#language">Language Reference</a>
        <a href="#literals">Literals: Functions, Objects and Arrays</a>
        <a href="#lexical-scope">Lexical Scoping and Variable Safety</a>
        <a href="#conditionals">If, Else, Unless, and Conditional Assignment</a>
        <a href="#splats">Splats...</a>
        <a href="#loops">Loops and Comprehensions</a>
        <a href="#slices">Array Slicing and Splicing</a>
        <a href="#expressions">Everything is an Expression</a>
        <a href="#operators">Operators and Aliases</a>
        <a href="#classes">Classes, Inheritance, and Super</a>
        <a href="#destructuring">Destructuring Assignment</a>
        <a href="#fat-arrow">Bound and Generator Functions</a>
        <a href="#embedded">Embedded JavaScript</a>
        <a href="#switch">Switch and Try/Catch</a>
        <a href="#comparisons">Chained Comparisons</a>
        <a href="#strings">String Interpolation, Block Strings, and Block Comments</a>
        <a href="#regexes">Block Regular Expressions</a>
        <a href="#cake">Cake, and Cakefiles</a>
        <a href="#source-maps">Source Maps</a>
        <a href="#scripts">"text/coffeescript" Script Tags</a>
        <a href="#resources">Books, Screencasts, Examples and Resources</a>
        <a href="#changelog">Change Log</a>
      </div>
    </div>
    <div class="navigation try">
      <div class="button">
        Try CoffeeScript
        <div class="repl_bridge"></div>
      </div>
      <div class="contents repl_wrapper">
        <div class="code">
          <div class="screenshadow tl"></div>
          <div class="screenshadow tr"></div>
          <div class="screenshadow bl"></div>
          <div class="screenshadow br"></div>
          <div id="repl_source_wrap">
            <textarea id="repl_source" rows="100" spellcheck="false">alert "Hello CoffeeScript!"</textarea>
          </div>
          <div id="repl_results_wrap"><pre id="repl_results"></pre></div>
          <div class="minibutton dark run" title="Ctrl-Enter">Run</div>
          <a class="minibutton permalink" id="repl_permalink">Link</a>
          <br class="clear" />
        </div>
      </div>
    </div>
    <div class="navigation annotated">
      <div class="button">
        Annotated Source
      </div>
      <div class="contents menu">
        <a href="documentation/docs/grammar.html">Grammar Rules &mdash; src/grammar</a>
        <a href="documentation/docs/lexer.html">Lexing Tokens &mdash; src/lexer</a>
        <a href="documentation/docs/rewriter.html">The Rewriter &mdash; src/rewriter</a>
        <a href="documentation/docs/nodes.html">The Syntax Tree &mdash; src/nodes</a>
        <a href="documentation/docs/scope.html">Lexical Scope &mdash; src/scope</a>
        <a href="documentation/docs/helpers.html">Helpers &amp; Utility Functions &mdash; src/helpers</a>
        <a href="documentation/docs/coffee-script.html">The CoffeeScript Module &mdash; src/coffee-script</a>
        <a href="documentation/docs/cake.html">Cake &amp; Cakefiles &mdash; src/cake</a>
        <a href="documentation/docs/command.html">"coffee" Command-Line Utility &mdash; src/command</a>
        <a href="documentation/docs/optparse.html">Option Parsing &mdash; src/optparse</a>
        <a href="documentation/docs/repl.html">Interactive REPL &mdash; src/repl</a>
        <a href="documentation/docs/sourcemap.html">Source Maps &mdash; src/sourcemap</a>
      </div>
    </div>
  </div>

  <div class="container">
    <span class="bookmark" id="top"></span>

    <p>
      <b>CoffeeScript is a little language that compiles into JavaScript.</b>
      Underneath that awkward Java-esque patina, JavaScript has always had
      a gorgeous heart. CoffeeScript is an attempt to expose
      the good parts of JavaScript in a simple way.
    </p>

    <p>
      The golden rule of CoffeeScript is: <i>"It's just JavaScript"</i>. The code
      compiles one-to-one into the equivalent JS, and there is
      no interpretation at runtime. You can use any existing JavaScript library
      seamlessly from CoffeeScript (and vice-versa). The compiled output is
      readable and pretty-printed, will work in every JavaScript runtime, and tends
      to run as fast or faster than the equivalent handwritten JavaScript.
    </p>

    <p>
      <b>Latest Version:</b>
      <a href="http://github.com/jashkenas/coffeescript/tarball/1.10.0">1.10.0</a>
    </p>

    <pre>npm install -g coffee-script</pre>

    <h2>
      <span id="overview" class="bookmark"></span>
      Overview
    </h2>

    <p><i>CoffeeScript on the left, compiled JavaScript output on the right.</i></p>

    <div class='code'><pre><code><span class="comment"># Assignment:</span>
number   = <span class="number">42</span>
opposite = <span class="literal">true</span>

<span class="comment"># Conditions:</span>
number = -<span class="number">42</span> <span class="keyword">if</span> opposite

<span class="comment"># Functions:</span>
<span class="function"><span class="title">square</span> = <span class="params">(x)</span> -&gt;</span> x * x

<span class="comment"># Arrays:</span>
list = [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>]

<span class="comment"># Objects:</span>
math =
  <span class="attribute">root</span>:   Math.sqrt
  <span class="attribute">square</span>: square
  <span class="attribute">cube</span>:   <span class="function"><span class="params">(x)</span> -&gt;</span> x * square x

<span class="comment"># Splats:</span>
<span class="function"><span class="title">race</span> = <span class="params">(winner, runners...)</span> -&gt;</span>
  <span class="built_in">print</span> winner, runners

<span class="comment"># Existence:</span>
alert <span class="string">"I knew it!"</span> <span class="keyword">if</span> elvis?

<span class="comment"># Array comprehensions:</span>
cubes = (math.cube num <span class="keyword">for</span> num <span class="keyword">in</span> list)
</code></pre><pre><code><span class="keyword">var</span> cubes, list, math, num, number, opposite, race, square,
  slice = [].slice;

number = <span class="number">42</span>;

opposite = <span class="literal">true</span>;

<span class="keyword">if</span> (opposite) {
  number = -<span class="number">42</span>;
}

square = <span class="function"><span class="keyword">function</span><span class="params">(x)</span> {</span>
  <span class="keyword">return</span> x * x;
};

list = [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>];

math = {
  root: <span class="built_in">Math</span>.sqrt,
  square: square,
  cube: <span class="function"><span class="keyword">function</span><span class="params">(x)</span> {</span>
    <span class="keyword">return</span> x * square(x);
  }
};

race = <span class="function"><span class="keyword">function</span><span class="params">()</span> {</span>
  <span class="keyword">var</span> runners, winner;
  winner = <span class="built_in">arguments</span>[<span class="number">0</span>], runners = <span class="number">2</span> &lt;= <span class="built_in">arguments</span>.length ? slice.call(<span class="built_in">arguments</span>, <span class="number">1</span>) : [];
  <span class="keyword">return</span> print(winner, runners);
};

<span class="keyword">if</span> (<span class="keyword">typeof</span> elvis !== <span class="string">"undefined"</span> &amp;&amp; elvis !== <span class="literal">null</span>) {
  alert(<span class="string">"I knew it!"</span>);
}

cubes = (<span class="function"><span class="keyword">function</span><span class="params">()</span> {</span>
  <span class="keyword">var</span> i, len, results;
  results = [];
  <span class="keyword">for</span> (i = <span class="number">0</span>, len = list.length; i &lt; len; i++) {
    num = list[i];
    results.push(math.cube(num));
  }
  <span class="keyword">return</span> results;
})();
</code></pre><script>window.example1 = "# Assignment:\nnumber   = 42\nopposite = true\n\n# Conditions:\nnumber = -42 if opposite\n\n# Functions:\nsquare = (x) -> x * x\n\n# Arrays:\nlist = [1, 2, 3, 4, 5]\n\n# Objects:\nmath =\n  root:   Math.sqrt\n  square: square\n  cube:   (x) -> x * square x\n\n# Splats:\nrace = (winner, runners...) ->\n  print winner, runners\n\n# Existence:\nalert \"I knew it!\" if elvis?\n\n# Array comprehensions:\ncubes = (math.cube num for num in list)\n"</script><div class='minibutton ok' onclick='javascript: var cubes, list, math, num, number, opposite, race, square,
  slice = [].slice;

number = 42;

opposite = true;

if (opposite) {
  number = -42;
}

square = function(x) {
  return x * x;
};

list = [1, 2, 3, 4, 5];

math = {
  root: Math.sqrt,
  square: square,
  cube: function(x) {
    return x * square(x);
  }
};

race = function() {
  var runners, winner;
  winner = arguments[0], runners = 2 <= arguments.length ? slice.call(arguments, 1) : [];
  return print(winner, runners);
};

if (typeof elvis !== "undefined" && elvis !== null) {
  alert("I knew it!");
}

cubes = (function() {
  var i, len, results;
  results = [];
  for (i = 0, len = list.length; i < len; i++) {
    num = list[i];
    results.push(math.cube(num));
  }
  return results;
})();
;alert(cubes);'>run: cubes</div><br class='clear' /></div>

    <h2>
      <span id="installation" class="bookmark"></span>
      Installation
    </h2>

    <p>
      The CoffeeScript compiler is itself
      <a href="documentation/docs/grammar.html">written in CoffeeScript</a>,
      using the <a href="http://jison.org">Jison parser generator</a>. The
      command-line version of <code>coffee</code> is available as a
      <a href="http://nodejs.org/">Node.js</a> utility. The
      <a href="extras/coffee-script.js">core compiler</a> however, does not
      depend on Node, and can be run in any JavaScript environment, or in the
      browser (see "Try CoffeeScript", above).
    </p>

    <p>
      To install, first make sure you have a working copy of the latest stable version of
      <a href="http://nodejs.org/">Node.js</a>. You can then install CoffeeScript globally
      with <a href="http://npmjs.org">npm</a>:
    </p>

    <pre>
npm install -g coffee-script</pre>

    <p>
      When you need CoffeeScript as a dependency, install it locally:
    </p>

    <pre>
npm install --save coffee-script</pre>

    <p>
      If you'd prefer to install the latest <b>master</b> version of CoffeeScript, you
      can clone the CoffeeScript
      <a href="http://github.com/jashkenas/coffeescript">source repository</a>
      from GitHub, or download
      <a href="http://github.com/jashkenas/coffeescript/tarball/master">the source</a> directly.
      To install the latest master CoffeeScript compiler with npm:
    </p>

<pre>
npm install -g jashkenas/coffeescript</pre>

    <p>
      Or, if you want to install to <code>/usr/local</code>, and don't want to use
      npm to manage it, open the <code>coffee-script</code> directory and run:
    </p>

  <pre>
sudo bin/cake install</pre>

    <h2>
      <span id="usage" class="bookmark"></span>
      Usage
    </h2>

    <p>
      Once installed, you should have access to the <code>coffee</code> command,
      which can execute scripts, compile <code>.coffee</code> files into <code>.js</code>,
      and provide an interactive REPL. The <code>coffee</code> command takes the
      following options:
    </p>

    <table>
      <tr>
        <td><code>-c, --compile</code></td>
        <td>
          Compile a <code>.coffee</code> script into a <code>.js</code> JavaScript file
          of the same name.
        </td>
      </tr>
      <tr>
        <td><code>-m, --map</code></td>
        <td>
          Generate source maps alongside the compiled JavaScript files. Adds
          <code>sourceMappingURL</code> directives to the JavaScript as well.
        </td>
      </tr>
      <tr>
        <td width="25%"><code>-i, --interactive</code></td>
        <td>
          Launch an interactive CoffeeScript session to try short snippets.
          Identical to calling <code>coffee</code> with no arguments.
        </td>
      </tr>
      <tr>
        <td><code>-o, --output [DIR]</code></td>
        <td>
          Write out all compiled JavaScript files into the specified directory.
          Use in conjunction with <code>--compile</code> or <code>--watch</code>.
        </td>
      </tr>
      <tr>
        <td><code>-j, --join [FILE]</code></td>
        <td>
          Before compiling, concatenate all scripts together in the order they
          were passed, and write them into the specified file.
          Useful for building large projects.
        </td>
      </tr>
      <tr>
        <td><code>-w, --watch</code></td>
        <td>
          Watch files for changes, rerunning the specified command when any
          file is updated.
        </td>
      </tr>
      <tr>
        <td><code>-p, --print</code></td>
        <td>
          Instead of writing out the JavaScript as a file, print it
          directly to <b>stdout</b>.
        </td>
      </tr>
      <tr>
        <td><code>-s, --stdio</code></td>
        <td>
          Pipe in CoffeeScript to STDIN and get back JavaScript over STDOUT.
          Good for use with processes written in other languages. An example:<br />
          <code>cat src/cake.coffee | coffee -sc</code>
        </td>
      </tr>
      <tr>
        <td><code>-l, --literate</code></td>
        <td>
          Parses the code as Literate CoffeeScript. You only need to specify
          this when passing in code directly over <b>stdio</b>, or using some sort
          of extension-less file name.
        </td>
      </tr>
      <tr>
        <td><code>-e, --eval</code></td>
        <td>
          Compile and print a little snippet of CoffeeScript directly from the
          command line. For example:<br /><code>coffee -e "console.log num for num in [10..1]"</code>
        </td>
      </tr>
      <tr>
        <td><code>-b, --bare</code></td>
        <td>
          Compile the JavaScript without the
          <a href="#lexical-scope">top-level function safety wrapper</a>.
        </td>
      </tr>
      <tr>
        <td><code>-t, --tokens</code></td>
        <td>
          Instead of parsing the CoffeeScript, just lex it, and print out the
          token stream: <code>[IDENTIFIER square] [ASSIGN =] [PARAM_START (]</code> ...
        </td>
      </tr>
      <tr>
        <td><code>-n, --nodes</code></td>
        <td>
          Instead of compiling the CoffeeScript, just lex and parse it, and print
          out the parse tree:
<pre class="no_bar">
Expressions
  Assign
    Value "square"
    Code "x"
      Op *
        Value "x"
        Value "x"</pre>
        </td>
      </tr>
      <tr>
        <td><code>--nodejs</code></td>
        <td>
          The <code>node</code> executable has some useful options you can set,
          such as<br /> <code>--debug</code>, <code>--debug-brk</code>, <code>--max-stack-size</code>,
          and <code>--expose-gc</code>. Use this flag to forward options directly to Node.js.
          To pass multiple flags, use <code>--nodejs</code> multiple times.
        </td>
      </tr>
    </table>

    <p>
      <b>Examples:</b>
    </p>

    <ul>
      <li>
        Compile a directory tree of <code>.coffee</code> files in <code>src</code> into a parallel
        tree of <code>.js</code> files in <code>lib</code>:<br />
        <code>coffee --compile --output lib/ src/</code>
      </li>
      <li>
        Watch a file for changes, and recompile it every time the file is saved:<br />
        <code>coffee --watch --compile experimental.coffee</code>
      </li>
      <li>
        Concatenate a list of files into a single script:<br />
        <code>coffee --join project.js --compile src/*.coffee</code>
      </li>
      <li>
        Print out the compiled JS from a one-liner:<br />
        <code>coffee -bpe "alert i for i in [0..10]"</code>
      </li>
      <li>
        All together now, watch and recompile an entire project as you work on it:<br />
        <code>coffee -o lib/ -cw src/</code>
      </li>
      <li>
        Start the CoffeeScript REPL (<code>Ctrl-D</code> to exit, <code>Ctrl-V</code>for multi-line):<br />
        <code>coffee</code>
      </li>
    </ul>

    <h2>
      <span id="literate" class="bookmark"></span>
      Literate CoffeeScript
    </h2>

    <p>
      Besides being used as an ordinary programming language, CoffeeScript may
      also be written in "literate" mode. If you name your file with a
      <code>.litcoffee</code> extension, you can write it as a Markdown document &mdash;
      a document that also happens to be executable CoffeeScript code. The compiler
      will treat any indented blocks (Markdown's way of indicating source code)
      as code, and ignore the rest as comments.
    </p>

    <p>
      Just for kicks, a little bit of the compiler is currently implemented in this fashion:
      See it
      <a href="https://gist.github.com/jashkenas/3fc3c1a8b1009c00d9df">as a document</a>,
      <a href="https://raw.github.com/jashkenas/coffeescript/master/src/scope.litcoffee">raw</a>,
      and <a href="http://cl.ly/LxEu">properly highlighted in a text editor</a>.
    </p>

    <p>
      I'm fairly excited about this direction for the language, and am looking
      forward to writing (and more importantly, reading) more programs in this style.
      More information about Literate CoffeeScript, including an
      <a href="https://github.com/jashkenas/journo">example program</a>,
      are <a href="http://ashkenas.com/literate-coffeescript">available in this blog post</a>.
    </p>

    <h2>
      <span id="language" class="bookmark"></span>
      Language Reference
    </h2>

    <p>
      <i>
        This reference is structured so that it can be read from top to bottom,
        if you like. Later sections use ideas and syntax previously introduced.
        Familiarity with JavaScript is assumed.
        In all of the following examples, the source CoffeeScript is provided on
        the left, and the direct compilation into JavaScript is on the right.
      </i>
    </p>

    <p>
      <i>
        Many of the examples can be run (where it makes sense) by pressing the <b>run</b>
        button on the right, and can be loaded into the "Try CoffeeScript"
        console by pressing the <b>load</b> button on the left.
      </i>
    <p>
      First, the basics: CoffeeScript uses significant whitespace to delimit blocks of code.
      You don't need to use semicolons <code>;</code> to terminate expressions,
      ending the line will do just as well (although semicolons can still
      be used to fit multiple expressions onto a single line).
      Instead of using curly braces
      <code>{ }</code> to surround blocks of code in <a href="#literals">functions</a>,
      <a href="#conditionals">if-statements</a>,
      <a href="#switch">switch</a>, and <a href="#try">try/catch</a>,
      use indentation.
    </p>

    <p>
      You don't need to use parentheses to invoke a function if you're passing
      arguments. The implicit call wraps forward to the end of the line or block expression.<br />
      <code>console.log sys.inspect object</code> &rarr; <code>console.log(sys.inspect(object));</code>
    </p>

    <p>
      <span id="literals" class="bookmark"></span>
      <b class="header">Functions</b>
      Functions are defined by an optional list of parameters in parentheses,
      an arrow, and the function body. The empty function looks like this:
      <code>-></code>
    </p>
    <div class='code'><pre><code><span class="function"><span class="title">square</span> = <span class="params">(x)</span> -&gt;</span> x * x
<span class="function"><span class="title">cube</span>   = <span class="params">(x)</span> -&gt;</span> square(x) * x
</code></pre><pre><code><span class="keyword">var</span> cube, square;

square = <span class="function"><span class="keyword">function</span><span class="params">(x)</span> {</span>
  <span class="keyword">return</span> x * x;
};

cube = <span class="function"><span class="keyword">function</span><span class="params">(x)</span> {</span>
  <span class="keyword">return</span> square(x) * x;
};
</code></pre><script>window.example2 = "square = (x) -> x * x\ncube   = (x) -> square(x) * x\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example2);'>load</div><div class='minibutton ok' onclick='javascript: var cube, square;

square = function(x) {
  return x * x;
};

cube = function(x) {
  return square(x) * x;
};
;alert(cube(5));'>run: cube(5)</div><br class='clear' /></div>
    <p>
      Functions may also have default values for arguments, which will be used
      if the incoming argument is missing (<code>null</code> or <code>undefined</code>).
    </p>
    <div class='code'><pre><code><span class="function"><span class="title">fill</span> = <span class="params">(container, liquid = <span class="string">"coffee"</span>)</span> -&gt;</span>
  <span class="string">"Filling the <span class="subst">#{container}</span> with <span class="subst">#{liquid}</span>..."</span>
</code></pre><pre><code><span class="keyword">var</span> fill;

fill = <span class="function"><span class="keyword">function</span><span class="params">(container, liquid)</span> {</span>
  <span class="keyword">if</span> (liquid == <span class="literal">null</span>) {
    liquid = <span class="string">"coffee"</span>;
  }
  <span class="keyword">return</span> <span class="string">"Filling the "</span> + container + <span class="string">" with "</span> + liquid + <span class="string">"..."</span>;
};
</code></pre><script>window.example3 = "fill = (container, liquid = \"coffee\") ->\n  \"Filling the #{container} with #{liquid}...\"\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example3);'>load</div><div class='minibutton ok' onclick='javascript: var fill;

fill = function(container, liquid) {
  if (liquid == null) {
    liquid = "coffee";
  }
  return "Filling the " + container + " with " + liquid + "...";
};
;alert(fill("cup"));'>run: fill("cup")</div><br class='clear' /></div>

    <p>
      <span id="objects_and_arrays" class="bookmark"></span>
      <b class="header">Objects and Arrays</b>
      The CoffeeScript literals for objects and arrays look very similar to
      their JavaScript cousins. When each property is listed on its own line,
      the commas are optional. Objects may be created using indentation instead
      of explicit braces, similar to <a href="http://yaml.org">YAML</a>.
    </p>
    <div class='code'><pre><code>song = [<span class="string">"do"</span>, <span class="string">"re"</span>, <span class="string">"mi"</span>, <span class="string">"fa"</span>, <span class="string">"so"</span>]

singers = {<span class="attribute">Jagger</span>: <span class="string">"Rock"</span>, <span class="attribute">Elvis</span>: <span class="string">"Roll"</span>}

bitlist = [
  <span class="number">1</span>, <span class="number">0</span>, <span class="number">1</span>
  <span class="number">0</span>, <span class="number">0</span>, <span class="number">1</span>
  <span class="number">1</span>, <span class="number">1</span>, <span class="number">0</span>
]

kids =
  <span class="attribute">brother</span>:
    <span class="attribute">name</span>: <span class="string">"Max"</span>
    <span class="attribute">age</span>:  <span class="number">11</span>
  <span class="attribute">sister</span>:
    <span class="attribute">name</span>: <span class="string">"Ida"</span>
    <span class="attribute">age</span>:  <span class="number">9</span>
</code></pre><pre><code><span class="keyword">var</span> bitlist, kids, singers, song;

song = [<span class="string">"do"</span>, <span class="string">"re"</span>, <span class="string">"mi"</span>, <span class="string">"fa"</span>, <span class="string">"so"</span>];

singers = {
  Jagger: <span class="string">"Rock"</span>,
  Elvis: <span class="string">"Roll"</span>
};

bitlist = [<span class="number">1</span>, <span class="number">0</span>, <span class="number">1</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>, <span class="number">0</span>];

kids = {
  brother: {
    name: <span class="string">"Max"</span>,
    age: <span class="number">11</span>
  },
  sister: {
    name: <span class="string">"Ida"</span>,
    age: <span class="number">9</span>
  }
};
</code></pre><script>window.example4 = "song = [\"do\", \"re\", \"mi\", \"fa\", \"so\"]\n\nsingers = {Jagger: \"Rock\", Elvis: \"Roll\"}\n\nbitlist = [\n  1, 0, 1\n  0, 0, 1\n  1, 1, 0\n]\n\nkids =\n  brother:\n    name: \"Max\"\n    age:  11\n  sister:\n    name: \"Ida\"\n    age:  9\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example4);'>load</div><div class='minibutton ok' onclick='javascript: var bitlist, kids, singers, song;

song = ["do", "re", "mi", "fa", "so"];

singers = {
  Jagger: "Rock",
  Elvis: "Roll"
};

bitlist = [1, 0, 1, 0, 0, 1, 1, 1, 0];

kids = {
  brother: {
    name: "Max",
    age: 11
  },
  sister: {
    name: "Ida",
    age: 9
  }
};
;alert(song.join(" ... "));'>run: song.join(" ... ")</div><br class='clear' /></div>
    <p>
      In JavaScript, you can't use reserved words, like <code>class</code>, as properties
      of an object, without quoting them as strings. CoffeeScript notices reserved words
      used as keys in objects and quotes them for you, so you don't have to worry
      about it (say, when using jQuery).
    </p>
    <div class='code'><pre><code>$('.account').attr class: 'active'

log object.class
</code></pre><pre><code>$(<span class="string">'.account'</span>).attr({
  <span class="string">"class"</span>: <span class="string">'active'</span>
});

log(object[<span class="string">"class"</span>]);
</code></pre><script>window.example5 = "$('.account').attr class: 'active'\n\nlog object.class\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example5);'>load</div><br class='clear' /></div>

    <p>
      <span id="lexical-scope" class="bookmark"></span>
      <b class="header">Lexical Scoping and Variable Safety</b>
      The CoffeeScript compiler takes care to make sure that all of your variables
      are properly declared within lexical scope &mdash; you never need to write
      <code>var</code> yourself.
    </p>
    <div class='code'><pre><code>outer = <span class="number">1</span>
<span class="function"><span class="title">changeNumbers</span> = -&gt;</span>
  inner = -<span class="number">1</span>
  outer = <span class="number">10</span>
inner = changeNumbers()</code></pre><pre><code><span class="keyword">var</span> changeNumbers, inner, outer;

outer = <span class="number">1</span>;

changeNumbers = <span class="function"><span class="keyword">function</span><span class="params">()</span> {</span>
  <span class="keyword">var</span> inner;
  inner = -<span class="number">1</span>;
  <span class="keyword">return</span> outer = <span class="number">10</span>;
};

inner = changeNumbers();
</code></pre><script>window.example6 = "outer = 1\nchangeNumbers = ->\n  inner = -1\n  outer = 10\ninner = changeNumbers()"</script><div class='minibutton load' onclick='javascript: loadConsole(example6);'>load</div><div class='minibutton ok' onclick='javascript: var changeNumbers, inner, outer;

outer = 1;

changeNumbers = function() {
  var inner;
  inner = -1;
  return outer = 10;
};

inner = changeNumbers();
;alert(inner);'>run: inner</div><br class='clear' /></div>
    <p>
      Notice how all of the variable declarations have been pushed up to
      the top of the closest scope, the first time they appear.
      <b>outer</b> is not redeclared within the inner function, because it's
      already in scope; <b>inner</b> within the function, on the other hand,
      should not be able to change the value of the external variable of the same name, and
      therefore has a declaration of its own.
    </p>
    <p>
      This behavior is effectively identical to Ruby's scope for local variables.
      Because you don't have direct access to the <code>var</code> keyword,
      it's impossible to shadow an outer variable on purpose, you may only refer
      to it. So be careful that you're not reusing the name of an external
      variable accidentally, if you're writing a deeply nested function.
    </p>
    <p>
      Although suppressed within this documentation for clarity, all
      CoffeeScript output is wrapped in an anonymous function:
      <code>(function(){ ... })();</code> This safety wrapper, combined with the
      automatic generation of the <code>var</code> keyword, make it exceedingly difficult
      to pollute the global namespace by accident.
    </p>
    <p>
      If you'd like to create top-level variables for other scripts to use,
      attach them as properties on <b>window</b>, or on the <b>exports</b>
      object in CommonJS. The <b>existential operator</b> (covered below), gives you a
      reliable way to figure out where to add them; if you're targeting both
      CommonJS and the browser: <code>exports ? this</code>
    </p>

    <p>
      <span id="conditionals" class="bookmark"></span>
      <b class="header">If, Else, Unless, and Conditional Assignment</b>
      <b>If/else</b> statements can be written without the use of parentheses and
      curly brackets. As with functions and other block expressions,
      multi-line conditionals are delimited by indentation. There's also a handy
      postfix form, with the <code>if</code> or <code>unless</code> at the end.
    </p>
    <p>
      CoffeeScript can compile <b>if</b> statements into JavaScript expressions,
      using the ternary operator when possible, and closure wrapping otherwise. There
      is no explicit ternary statement in CoffeeScript &mdash; you simply use
      a regular <b>if</b> statement on a single line.
    </p>
    <div class='code'><pre><code>mood = greatlyImproved <span class="keyword">if</span> singing

<span class="keyword">if</span> happy <span class="keyword">and</span> knowsIt
  clapsHands()
  chaChaCha()
<span class="keyword">else</span>
  showIt()

date = <span class="keyword">if</span> friday <span class="keyword">then</span> sue <span class="keyword">else</span> jill
</code></pre><pre><code><span class="keyword">var</span> date, mood;

<span class="keyword">if</span> (singing) {
  mood = greatlyImproved;
}

<span class="keyword">if</span> (happy &amp;&amp; knowsIt) {
  clapsHands();
  chaChaCha();
} <span class="keyword">else</span> {
  showIt();
}

date = friday ? sue : jill;
</code></pre><script>window.example7 = "mood = greatlyImproved if singing\n\nif happy and knowsIt\n  clapsHands()\n  chaChaCha()\nelse\n  showIt()\n\ndate = if friday then sue else jill\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example7);'>load</div><br class='clear' /></div>

    <p>
      <span id="splats" class="bookmark"></span>
      <b class="header">Splats...</b>
      The JavaScript <b>arguments object</b> is a useful way to work with
      functions that accept variable numbers of arguments. CoffeeScript provides
      splats <code>...</code>, both for function definition as well as invocation,
      making variable numbers of arguments a little bit more palatable.
    </p>
    <div class='code'><pre><code>gold = silver = rest = <span class="string">"unknown"</span>

<span class="function"><span class="title">awardMedals</span> = <span class="params">(first, second, others...)</span> -&gt;</span>
  gold   = first
  silver = second
  rest   = others

contenders = [
  <span class="string">"Michael Phelps"</span>
  <span class="string">"Liu Xiang"</span>
  <span class="string">"Yao Ming"</span>
  <span class="string">"Allyson Felix"</span>
  <span class="string">"Shawn Johnson"</span>
  <span class="string">"Roman Sebrle"</span>
  <span class="string">"Guo Jingjing"</span>
  <span class="string">"Tyson Gay"</span>
  <span class="string">"Asafa Powell"</span>
  <span class="string">"Usain Bolt"</span>
]

awardMedals contenders...

alert <span class="string">"Gold: "</span> + gold
alert <span class="string">"Silver: "</span> + silver
alert <span class="string">"The Field: "</span> + rest
</code></pre><pre><code><span class="keyword">var</span> awardMedals, contenders, gold, rest, silver,
  slice = [].slice;

gold = silver = rest = <span class="string">"unknown"</span>;

awardMedals = <span class="function"><span class="keyword">function</span><span class="params">()</span> {</span>
  <span class="keyword">var</span> first, others, second;
  first = <span class="built_in">arguments</span>[<span class="number">0</span>], second = <span class="built_in">arguments</span>[<span class="number">1</span>], others = <span class="number">3</span> &lt;= <span class="built_in">arguments</span>.length ? slice.call(<span class="built_in">arguments</span>, <span class="number">2</span>) : [];
  gold = first;
  silver = second;
  <span class="keyword">return</span> rest = others;
};

contenders = [<span class="string">"Michael Phelps"</span>, <span class="string">"Liu Xiang"</span>, <span class="string">"Yao Ming"</span>, <span class="string">"Allyson Felix"</span>, <span class="string">"Shawn Johnson"</span>, <span class="string">"Roman Sebrle"</span>, <span class="string">"Guo Jingjing"</span>, <span class="string">"Tyson Gay"</span>, <span class="string">"Asafa Powell"</span>, <span class="string">"Usain Bolt"</span>];

awardMedals.apply(<span class="literal">null</span>, contenders);

alert(<span class="string">"Gold: "</span> + gold);

alert(<span class="string">"Silver: "</span> + silver);

alert(<span class="string">"The Field: "</span> + rest);
</code></pre><script>window.example8 = "gold = silver = rest = \"unknown\"\n\nawardMedals = (first, second, others...) ->\n  gold   = first\n  silver = second\n  rest   = others\n\ncontenders = [\n  \"Michael Phelps\"\n  \"Liu Xiang\"\n  \"Yao Ming\"\n  \"Allyson Felix\"\n  \"Shawn Johnson\"\n  \"Roman Sebrle\"\n  \"Guo Jingjing\"\n  \"Tyson Gay\"\n  \"Asafa Powell\"\n  \"Usain Bolt\"\n]\n\nawardMedals contenders...\n\nalert \"Gold: \" + gold\nalert \"Silver: \" + silver\nalert \"The Field: \" + rest\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example8);'>load</div><div class='minibutton ok' onclick='javascript: var awardMedals, contenders, gold, rest, silver,
  slice = [].slice;

gold = silver = rest = "unknown";

awardMedals = function() {
  var first, others, second;
  first = arguments[0], second = arguments[1], others = 3 <= arguments.length ? slice.call(arguments, 2) : [];
  gold = first;
  silver = second;
  return rest = others;
};

contenders = ["Michael Phelps", "Liu Xiang", "Yao Ming", "Allyson Felix", "Shawn Johnson", "Roman Sebrle", "Guo Jingjing", "Tyson Gay", "Asafa Powell", "Usain Bolt"];

awardMedals.apply(null, contenders);

alert("Gold: " + gold);

alert("Silver: " + silver);

alert("The Field: " + rest);
;'>run</div><br class='clear' /></div>

    <p>
      <span id="loops" class="bookmark"></span>
      <b class="header">Loops and Comprehensions</b>
      Most of the loops you'll write in CoffeeScript will be <b>comprehensions</b>
      over arrays, objects, and ranges. Comprehensions replace (and compile into)
      <b>for</b> loops, with optional guard clauses and the value of the current array index.
      Unlike for loops, array comprehensions are expressions, and can be returned
      and assigned.
    </p>
    <div class='code'><pre><code><span class="comment"># Eat lunch.</span>
eat food <span class="keyword">for</span> food <span class="keyword">in</span> [<span class="string">'toast'</span>, <span class="string">'cheese'</span>, <span class="string">'wine'</span>]

<span class="comment"># Fine five course dining.</span>
courses = [<span class="string">'greens'</span>, <span class="string">'caviar'</span>, <span class="string">'truffles'</span>, <span class="string">'roast'</span>, <span class="string">'cake'</span>]
menu i + <span class="number">1</span>, dish <span class="keyword">for</span> dish, i <span class="keyword">in</span> courses

<span class="comment"># Health conscious meal.</span>
foods = [<span class="string">'broccoli'</span>, <span class="string">'spinach'</span>, <span class="string">'chocolate'</span>]
eat food <span class="keyword">for</span> food <span class="keyword">in</span> foods <span class="keyword">when</span> food <span class="keyword">isnt</span> <span class="string">'chocolate'</span>
</code></pre><pre><code><span class="keyword">var</span> courses, dish, food, foods, i, j, k, l, len, len1, len2, ref;

ref = [<span class="string">'toast'</span>, <span class="string">'cheese'</span>, <span class="string">'wine'</span>];
<span class="keyword">for</span> (j = <span class="number">0</span>, len = ref.length; j &lt; len; j++) {
  food = ref[j];
  eat(food);
}

courses = [<span class="string">'greens'</span>, <span class="string">'caviar'</span>, <span class="string">'truffles'</span>, <span class="string">'roast'</span>, <span class="string">'cake'</span>];

<span class="keyword">for</span> (i = k = <span class="number">0</span>, len1 = courses.length; k &lt; len1; i = ++k) {
  dish = courses[i];
  menu(i + <span class="number">1</span>, dish);
}

foods = [<span class="string">'broccoli'</span>, <span class="string">'spinach'</span>, <span class="string">'chocolate'</span>];

<span class="keyword">for</span> (l = <span class="number">0</span>, len2 = foods.length; l &lt; len2; l++) {
  food = foods[l];
  <span class="keyword">if</span> (food !== <span class="string">'chocolate'</span>) {
    eat(food);
  }
}
</code></pre><script>window.example9 = "# Eat lunch.\neat food for food in ['toast', 'cheese', 'wine']\n\n# Fine five course dining.\ncourses = ['greens', 'caviar', 'truffles', 'roast', 'cake']\nmenu i + 1, dish for dish, i in courses\n\n# Health conscious meal.\nfoods = ['broccoli', 'spinach', 'chocolate']\neat food for food in foods when food isnt 'chocolate'\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example9);'>load</div><br class='clear' /></div>
    <p>
      Comprehensions should be able to handle most places where you otherwise
      would use a loop, <b>each</b>/<b>forEach</b>, <b>map</b>, or <b>select</b>/<b>filter</b>, for example:
      <code>shortNames = (name for name in list when name.length &lt; 5)</code><br />
      If you know the start and end of your loop, or would like to step through
      in fixed-size increments, you can use a range to specify the start and
      end of your comprehension.
    </p>
    <div class='code'><pre><code>countdown = (num <span class="keyword">for</span> num <span class="keyword">in</span> [<span class="number">10.</span><span class="number">.1</span>])
</code></pre><pre><code><span class="keyword">var</span> countdown, num;

countdown = (<span class="function"><span class="keyword">function</span><span class="params">()</span> {</span>
  <span class="keyword">var</span> i, results;
  results = [];
  <span class="keyword">for</span> (num = i = <span class="number">10</span>; i &gt;= <span class="number">1</span>; num = --i) {
    results.push(num);
  }
  <span class="keyword">return</span> results;
})();
</code></pre><script>window.example10 = "countdown = (num for num in [10..1])\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example10);'>load</div><div class='minibutton ok' onclick='javascript: var countdown, num;

countdown = (function() {
  var i, results;
  results = [];
  for (num = i = 10; i >= 1; num = --i) {
    results.push(num);
  }
  return results;
})();
;alert(countdown);'>run: countdown</div><br class='clear' /></div>
    <p>
      Note how because we are assigning the value of the comprehensions to a
      variable in the example above, CoffeeScript is collecting the result of
      each iteration into an array. Sometimes functions end with loops that are
      intended to run only for their side-effects. Be careful that you're not
      accidentally returning the results of the comprehension in these cases,
      by adding a meaningful return value &mdash; like <code>true</code> &mdash; or <code>null</code>,
      to the bottom of your function.
    </p>
    <p>
      To step through a range comprehension in fixed-size chunks,
      use <code>by</code>, for example:<br />
      <code>evens = (x for x in [0..10] by 2)</code>
    </p>
    <p>
      If you don't need the current iteration value you may omit it:<br />
      <code>browser.closeCurrentTab() for [0...count]</code>
    </p>
    <p>
      Comprehensions can also be used to iterate over the keys and values in
      an object. Use <code>of</code> to signal comprehension over the properties of
      an object instead of the values in an array.
    </p>
    <div class='code'><pre><code>yearsOld = <span class="attribute">max</span>: <span class="number">10</span>, <span class="attribute">ida</span>: <span class="number">9</span>, <span class="attribute">tim</span>: <span class="number">11</span>

ages = <span class="keyword">for</span> child, age <span class="keyword">of</span> yearsOld
  <span class="string">"<span class="subst">#{child}</span> is <span class="subst">#{age}</span>"</span>
</code></pre><pre><code><span class="keyword">var</span> age, ages, child, yearsOld;

yearsOld = {
  max: <span class="number">10</span>,
  ida: <span class="number">9</span>,
  tim: <span class="number">11</span>
};

ages = (<span class="function"><span class="keyword">function</span><span class="params">()</span> {</span>
  <span class="keyword">var</span> results;
  results = [];
  <span class="keyword">for</span> (child <span class="keyword">in</span> yearsOld) {
    age = yearsOld[child];
    results.push(child + <span class="string">" is "</span> + age);
  }
  <span class="keyword">return</span> results;
})();
</code></pre><script>window.example11 = "yearsOld = max: 10, ida: 9, tim: 11\n\nages = for child, age of yearsOld\n  \"#{child} is #{age}\"\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example11);'>load</div><div class='minibutton ok' onclick='javascript: var age, ages, child, yearsOld;

yearsOld = {
  max: 10,
  ida: 9,
  tim: 11
};

ages = (function() {
  var results;
  results = [];
  for (child in yearsOld) {
    age = yearsOld[child];
    results.push(child + " is " + age);
  }
  return results;
})();
;alert(ages.join(", "));'>run: ages.join(", ")</div><br class='clear' /></div>
    <p>
      If you would like to iterate over just the keys that are defined on the
      object itself, by adding a <code>hasOwnProperty</code>
      check to avoid properties that may be inherited from the prototype, use<br />
      <code>for own key, value of object</code>
    </p>
    <p>
      The only low-level loop that CoffeeScript provides is the <b>while</b> loop. The
      main difference from JavaScript is that the <b>while</b> loop can be used
      as an expression, returning an array containing the result of each iteration
      through the loop.
    </p>
    <div class='code'><pre><code><span class="comment"># Econ 101</span>
<span class="keyword">if</span> <span class="keyword">this</span>.studyingEconomics
  buy()  <span class="keyword">while</span> supply &gt; demand
  sell() <span class="keyword">until</span> supply &gt; demand

<span class="comment"># Nursery Rhyme</span>
num = <span class="number">6</span>
lyrics = <span class="keyword">while</span> num -= <span class="number">1</span>
  <span class="string">"<span class="subst">#{num}</span> little monkeys, jumping on the bed.
    One fell out and bumped his head."</span>
</code></pre><pre><code><span class="keyword">var</span> lyrics, num;

<span class="keyword">if</span> (<span class="keyword">this</span>.studyingEconomics) {
  <span class="keyword">while</span> (supply &gt; demand) {
    buy();
  }
  <span class="keyword">while</span> (!(supply &gt; demand)) {
    sell();
  }
}

num = <span class="number">6</span>;

lyrics = (<span class="function"><span class="keyword">function</span><span class="params">()</span> {</span>
  <span class="keyword">var</span> results;
  results = [];
  <span class="keyword">while</span> (num -= <span class="number">1</span>) {
    results.push(num + <span class="string">" little monkeys, jumping on the bed. One fell out and bumped his head."</span>);
  }
  <span class="keyword">return</span> results;
})();
</code></pre><script>window.example12 = "# Econ 101\nif this.studyingEconomics\n  buy()  while supply > demand\n  sell() until supply > demand\n\n# Nursery Rhyme\nnum = 6\nlyrics = while num -= 1\n  \"#{num} little monkeys, jumping on the bed.\n    One fell out and bumped his head.\"\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example12);'>load</div><div class='minibutton ok' onclick='javascript: var lyrics, num;

if (this.studyingEconomics) {
  while (supply > demand) {
    buy();
  }
  while (!(supply > demand)) {
    sell();
  }
}

num = 6;

lyrics = (function() {
  var results;
  results = [];
  while (num -= 1) {
    results.push(num + " little monkeys, jumping on the bed. One fell out and bumped his head.");
  }
  return results;
})();
;alert(lyrics.join("
"));'>run: lyrics.join("
")</div><br class='clear' /></div>
    <p>
      For readability, the <b>until</b> keyword is equivalent to <code>while not</code>,
      and the <b>loop</b> keyword is equivalent to <code>while true</code>.
    </p>
    <p>
      When using a JavaScript loop to generate functions, it's common to insert
      a closure wrapper in order to ensure that loop variables are closed over,
      and all the generated functions don't just share the final values. CoffeeScript
      provides the <code>do</code> keyword, which immediately invokes a passed function,
      forwarding any arguments.
    </p>
    <div class='code'><pre><code><span class="keyword">for</span> filename <span class="keyword">in</span> list
  <span class="keyword">do</span> <span class="function"><span class="params">(filename)</span> -&gt;</span>
    fs.readFile filename, <span class="function"><span class="params">(err, contents)</span> -&gt;</span>
      compile filename, contents.toString()</code></pre><pre><code><span class="keyword">var</span> filename, fn, i, len;

fn = <span class="function"><span class="keyword">function</span><span class="params">(filename)</span> {</span>
  <span class="keyword">return</span> fs.readFile(filename, <span class="function"><span class="keyword">function</span><span class="params">(err, contents)</span> {</span>
    <span class="keyword">return</span> compile(filename, contents.toString());
  });
};
<span class="keyword">for</span> (i = <span class="number">0</span>, len = list.length; i &lt; len; i++) {
  filename = list[i];
  fn(filename);
}
</code></pre><script>window.example13 = "for filename in list\n  do (filename) ->\n    fs.readFile filename, (err, contents) ->\n      compile filename, contents.toString()"</script><div class='minibutton load' onclick='javascript: loadConsole(example13);'>load</div><br class='clear' /></div>

    <p>
      <span id="slices" class="bookmark"></span>
      <b class="header">Array Slicing and Splicing with Ranges</b>
      Ranges can also be used to extract slices of arrays.
      With two dots (<code>3..6</code>), the range is inclusive (<code>3, 4, 5, 6</code>);
      with three dots (<code>3...6</code>), the range excludes the end (<code>3, 4, 5</code>).
      Slices indices have useful defaults. An omitted first index defaults to
      zero and an omitted second index defaults to the size of the array.
    </p>
    <div class='code'><pre><code>numbers = [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">7</span>, <span class="number">8</span>, <span class="number">9</span>]

start   = numbers[<span class="number">0.</span><span class="number">.2</span>]

middle  = numbers[<span class="number">3.</span>..-<span class="number">2</span>]

end     = numbers[-<span class="number">2.</span>.]

copy    = numbers[..]
</code></pre><pre><code><span class="keyword">var</span> copy, end, middle, numbers, start;

numbers = [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">7</span>, <span class="number">8</span>, <span class="number">9</span>];

start = numbers.slice(<span class="number">0</span>, <span class="number">3</span>);

middle = numbers.slice(<span class="number">3</span>, -<span class="number">2</span>);

end = numbers.slice(-<span class="number">2</span>);

copy = numbers.slice(<span class="number">0</span>);
</code></pre><script>window.example14 = "numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9]\n\nstart   = numbers[0..2]\n\nmiddle  = numbers[3...-2]\n\nend     = numbers[-2..]\n\ncopy    = numbers[..]\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example14);'>load</div><div class='minibutton ok' onclick='javascript: var copy, end, middle, numbers, start;

numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9];

start = numbers.slice(0, 3);

middle = numbers.slice(3, -2);

end = numbers.slice(-2);

copy = numbers.slice(0);
;alert(middle);'>run: middle</div><br class='clear' /></div>
    <p>
      The same syntax can be used with assignment to replace a segment of an array
      with new values, splicing it.
    </p>
    <div class='code'><pre><code>numbers = [<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">7</span>, <span class="number">8</span>, <span class="number">9</span>]

numbers[<span class="number">3.</span><span class="number">.6</span>] = [-<span class="number">3</span>, -<span class="number">4</span>, -<span class="number">5</span>, -<span class="number">6</span>]
</code></pre><pre><code><span class="keyword">var</span> numbers, ref;

numbers = [<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">7</span>, <span class="number">8</span>, <span class="number">9</span>];

[].splice.apply(numbers, [<span class="number">3</span>, <span class="number">4</span>].concat(ref = [-<span class="number">3</span>, -<span class="number">4</span>, -<span class="number">5</span>, -<span class="number">6</span>])), ref;
</code></pre><script>window.example15 = "numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n\nnumbers[3..6] = [-3, -4, -5, -6]\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example15);'>load</div><div class='minibutton ok' onclick='javascript: var numbers, ref;

numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];

[].splice.apply(numbers, [3, 4].concat(ref = [-3, -4, -5, -6])), ref;
;alert(numbers);'>run: numbers</div><br class='clear' /></div>
    <p>
      Note that JavaScript strings are immutable, and can't be spliced.
    </p>
    <p>
      <span id="expressions" class="bookmark"></span>
      <b class="header">Everything is an Expression (at least, as much as possible)</b>
      You might have noticed how even though we don't add return statements
      to CoffeeScript functions, they nonetheless return their final value.
      The CoffeeScript compiler tries to make sure that all statements in the
      language can be used as expressions. Watch how the <code>return</code> gets
      pushed down into each possible branch of execution in the function
      below.
    </p>
    <div class='code'><pre><code><span class="function"><span class="title">grade</span> = <span class="params">(student)</span> -&gt;</span>
  <span class="keyword">if</span> student.excellentWork
    <span class="string">"A+"</span>
  <span class="keyword">else</span> <span class="keyword">if</span> student.okayStuff
    <span class="keyword">if</span> student.triedHard <span class="keyword">then</span> <span class="string">"B"</span> <span class="keyword">else</span> <span class="string">"B-"</span>
  <span class="keyword">else</span>
    <span class="string">"C"</span>

eldest = <span class="keyword">if</span> <span class="number">24</span> &gt; <span class="number">21</span> <span class="keyword">then</span> <span class="string">"Liz"</span> <span class="keyword">else</span> <span class="string">"Ike"</span></code></pre><pre><code><span class="keyword">var</span> eldest, grade;

grade = <span class="function"><span class="keyword">function</span><span class="params">(student)</span> {</span>
  <span class="keyword">if</span> (student.excellentWork) {
    <span class="keyword">return</span> <span class="string">"A+"</span>;
  } <span class="keyword">else</span> <span class="keyword">if</span> (student.okayStuff) {
    <span class="keyword">if</span> (student.triedHard) {
      <span class="keyword">return</span> <span class="string">"B"</span>;
    } <span class="keyword">else</span> {
      <span class="keyword">return</span> <span class="string">"B-"</span>;
    }
  } <span class="keyword">else</span> {
    <span class="keyword">return</span> <span class="string">"C"</span>;
  }
};

eldest = <span class="number">24</span> &gt; <span class="number">21</span> ? <span class="string">"Liz"</span> : <span class="string">"Ike"</span>;
</code></pre><script>window.example16 = "grade = (student) ->\n  if student.excellentWork\n    \"A+\"\n  else if student.okayStuff\n    if student.triedHard then \"B\" else \"B-\"\n  else\n    \"C\"\n\neldest = if 24 > 21 then \"Liz\" else \"Ike\""</script><div class='minibutton load' onclick='javascript: loadConsole(example16);'>load</div><div class='minibutton ok' onclick='javascript: var eldest, grade;

grade = function(student) {
  if (student.excellentWork) {
    return "A+";
  } else if (student.okayStuff) {
    if (student.triedHard) {
      return "B";
    } else {
      return "B-";
    }
  } else {
    return "C";
  }
};

eldest = 24 > 21 ? "Liz" : "Ike";
;alert(eldest);'>run: eldest</div><br class='clear' /></div>
    <p>
      Even though functions will always return their final value, it's both possible
      and encouraged to return early from a function body writing out the explicit
      return (<code>return value</code>), when you know that you're done.
    </p>
    <p>
      Because variable declarations occur at the top of scope, assignment can
      be used within expressions, even for variables that haven't been seen before:
    </p>
    <div class='code'><pre><code>six = (one = <span class="number">1</span>) + (two = <span class="number">2</span>) + (three = <span class="number">3</span>)
</code></pre><pre><code><span class="keyword">var</span> one, six, three, two;

six = (one = <span class="number">1</span>) + (two = <span class="number">2</span>) + (three = <span class="number">3</span>);
</code></pre><script>window.example17 = "six = (one = 1) + (two = 2) + (three = 3)\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example17);'>load</div><div class='minibutton ok' onclick='javascript: var one, six, three, two;

six = (one = 1) + (two = 2) + (three = 3);
;alert(six);'>run: six</div><br class='clear' /></div>
    <p>
      Things that would otherwise be statements in JavaScript, when used
      as part of an expression in CoffeeScript, are converted into expressions
      by wrapping them in a closure. This lets you do useful things, like assign
      the result of a comprehension to a variable:
    </p>
    <div class='code'><pre><code><span class="comment"># The first ten global properties.</span>

globals = (name <span class="keyword">for</span> name <span class="keyword">of</span> <span class="built_in">window</span>)[<span class="number">0.</span>.<span class="number">.10</span>]</code></pre><pre><code><span class="keyword">var</span> globals, name;

globals = ((<span class="function"><span class="keyword">function</span><span class="params">()</span> {</span>
  <span class="keyword">var</span> results;
  results = [];
  <span class="keyword">for</span> (name <span class="keyword">in</span> window) {
    results.push(name);
  }
  <span class="keyword">return</span> results;
})()).slice(<span class="number">0</span>, <span class="number">10</span>);
</code></pre><script>window.example18 = "# The first ten global properties.\n\nglobals = (name for name of window)[0...10]"</script><div class='minibutton load' onclick='javascript: loadConsole(example18);'>load</div><div class='minibutton ok' onclick='javascript: var globals, name;

globals = ((function() {
  var results;
  results = [];
  for (name in window) {
    results.push(name);
  }
  return results;
})()).slice(0, 10);
;alert(globals);'>run: globals</div><br class='clear' /></div>
    <p>
      As well as silly things, like passing a <b>try/catch</b> statement directly
      into a function call:
    </p>
    <div class='code'><pre><code>alert(
  <span class="keyword">try</span>
    nonexistent / <span class="literal">undefined</span>
  <span class="keyword">catch</span> error
    <span class="string">"And the error is ... <span class="subst">#{error}</span>"</span>
)
</code></pre><pre><code><span class="keyword">var</span> error;

alert((<span class="function"><span class="keyword">function</span><span class="params">()</span> {</span>
  <span class="keyword">var</span> error1;
  <span class="keyword">try</span> {
    <span class="keyword">return</span> nonexistent / <span class="keyword">void</span> <span class="number">0</span>;
  } <span class="keyword">catch</span> (error1) {
    error = error1;
    <span class="keyword">return</span> <span class="string">"And the error is ... "</span> + error;
  }
})());
</code></pre><script>window.example19 = "alert(\n  try\n    nonexistent / undefined\n  catch error\n    \"And the error is ... #{error}\"\n)\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example19);'>load</div><div class='minibutton ok' onclick='javascript: var error;

alert((function() {
  var error1;
  try {
    return nonexistent / void 0;
  } catch (error1) {
    error = error1;
    return "And the error is ... " + error;
  }
})());
;'>run</div><br class='clear' /></div>
    <p>
      There are a handful of statements in JavaScript that can't be meaningfully
      converted into expressions, namely <code>break</code>, <code>continue</code>,
      and <code>return</code>. If you make use of them within a block of code,
      CoffeeScript won't try to perform the conversion.
    </p>

    <p>
      <span id="operators" class="bookmark"></span>
      <b class="header">Operators and Aliases</b>
      Because the <code>==</code> operator frequently causes undesirable coercion,
      is intransitive, and has a different meaning than in other languages,
      CoffeeScript compiles <code>==</code> into <code>===</code>, and <code>!=</code> into
      <code>!==</code>.
      In addition, <code>is</code> compiles into <code>===</code>,
      and <code>isnt</code> into <code>!==</code>.
    </p>
    <p>
      You can use <code>not</code> as an alias for <code>!</code>.
    </p>
    <p>
      For logic, <code>and</code> compiles to <code>&amp;&amp;</code>, and <code>or</code>
      into <code>||</code>.
    </p>
    <p>
      Instead of a newline or semicolon, <code>then</code> can be used to separate
      conditions from expressions, in <b>while</b>,
      <b>if</b>/<b>else</b>, and <b>switch</b>/<b>when</b> statements.
    </p>
    <p>
      As in <a href="http://yaml.org/">YAML</a>, <code>on</code> and <code>yes</code>
      are the same as boolean <code>true</code>, while <code>off</code> and <code>no</code> are boolean <code>false</code>.
    </p>
    <p>
      <code>unless</code> can be used as the inverse of <code>if</code>.
    </p>
    <p>
      As a shortcut for <code>this.property</code>, you can use <code>@property</code>.
    </p>
    <p>
      You can use <code>in</code> to test for array presence, and <code>of</code> to
      test for JavaScript object-key presence.
    </p>
    <p>
      To simplify math expressions, <code>**</code> can be used for exponentiation
      and <code>//</code> performs integer division. <code>%</code> works just like in
      JavaScript, while <code>%%</code> provides
      <a href="http://en.wikipedia.org/wiki/Modulo_operation">“dividend dependent modulo”</a>:
    </p>
    <div class='code'><pre><code>-<span class="number">7</span> % <span class="number">5</span> == -<span class="number">2</span> <span class="comment"># The remainder of 7 / 5</span>
-<span class="number">7</span> %% <span class="number">5</span> == <span class="number">3</span> <span class="comment"># n %% 5 is always between 0 and 4</span>

tabs.selectTabAtIndex((tabs.currentIndex - count) %% tabs.length)
</code></pre><pre><code><span class="keyword">var</span> modulo = <span class="function"><span class="keyword">function</span><span class="params">(a, b)</span> {</span> <span class="keyword">return</span> (+a % (b = +b) + b) % b; };

-<span class="number">7</span> % <span class="number">5</span> === -<span class="number">2</span>;

modulo(-<span class="number">7</span>, <span class="number">5</span>) === <span class="number">3</span>;

tabs.selectTabAtIndex(modulo(tabs.currentIndex - count, tabs.length));
</code></pre><script>window.example20 = "-7 % 5 == -2 # The remainder of 7 / 5\n-7 %% 5 == 3 # n %% 5 is always between 0 and 4\n\ntabs.selectTabAtIndex((tabs.currentIndex - count) %% tabs.length)\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example20);'>load</div><br class='clear' /></div>
    <p>
      All together now:
    </p>

    <table class="definitions">
      <tr><th>CoffeeScript</th><th>JavaScript</th></tr>
      <tr><td><code>is</code></td><td><code>===</code></td></tr>
      <tr><td><code>isnt</code></td><td><code>!==</code></td></tr>
      <tr><td><code>not</code></td><td><code>!</code></td></tr>
      <tr><td><code>and</code></td><td><code>&amp;&amp;</code></td></tr>
      <tr><td><code>or</code></td><td><code>||</code></td></tr>
      <tr><td><code>true</code>, <code>yes</code>, <code>on</code></td><td><code>true</code></td></tr>
      <tr><td><code>false</code>, <code>no</code>, <code>off</code></td><td><code>false</code></td></tr>
      <tr><td><code>@</code>, <code>this</code></td><td><code>this</code></td></tr>
      <tr><td><code>of</code></td><td><code>in</code></td></tr>
      <tr><td><code>in</code></td><td><i><small>no JS equivalent</small></i></td></tr>
      <tr><td><code>a ** b</code></td><td><code>Math.pow(a, b)</code></td></tr>
      <tr><td><code>a // b</code></td><td><code>Math.floor(a / b)</code></td></tr>
      <tr><td><code>a %% b</code></td><td><code>(a % b + b) % b</code></td></tr>
    </table>

    <div class='code'><pre><code>launch() <span class="keyword">if</span> ignition <span class="keyword">is</span> <span class="literal">on</span>

volume = <span class="number">10</span> <span class="keyword">if</span> band <span class="keyword">isnt</span> SpinalTap

letTheWildRumpusBegin() <span class="keyword">unless</span> answer <span class="keyword">is</span> <span class="literal">no</span>

<span class="keyword">if</span> car.speed &lt; limit <span class="keyword">then</span> accelerate()

winner = <span class="literal">yes</span> <span class="keyword">if</span> pick <span class="keyword">in</span> [<span class="number">47</span>, <span class="number">92</span>, <span class="number">13</span>]

<span class="built_in">print</span> inspect <span class="string">"My name is <span class="subst">#{<span class="property">@name</span>}</span>"</span>
</code></pre><pre><code><span class="keyword">var</span> volume, winner;

<span class="keyword">if</span> (ignition === <span class="literal">true</span>) {
  launch();
}

<span class="keyword">if</span> (band !== SpinalTap) {
  volume = <span class="number">10</span>;
}

<span class="keyword">if</span> (answer !== <span class="literal">false</span>) {
  letTheWildRumpusBegin();
}

<span class="keyword">if</span> (car.speed &lt; limit) {
  accelerate();
}

<span class="keyword">if</span> (pick === <span class="number">47</span> || pick === <span class="number">92</span> || pick === <span class="number">13</span>) {
  winner = <span class="literal">true</span>;
}

print(inspect(<span class="string">"My name is "</span> + <span class="keyword">this</span>.name));
</code></pre><script>window.example21 = "launch() if ignition is on\n\nvolume = 10 if band isnt SpinalTap\n\nletTheWildRumpusBegin() unless answer is no\n\nif car.speed < limit then accelerate()\n\nwinner = yes if pick in [47, 92, 13]\n\nprint inspect \"My name is #{@name}\"\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example21);'>load</div><br class='clear' /></div>

    <p>
      <b class="header">The Existential Operator</b>
      It's a little difficult to check for the existence of a variable in
      JavaScript. <code>if (variable) ...</code> comes close, but fails for zero,
      the empty string, and false. CoffeeScript's existential operator <code>?</code> returns true unless
      a variable is <b>null</b> or <b>undefined</b>, which makes it analogous
      to Ruby's <code>nil?</code>
    </p>
    <p>
      It can also be used for safer conditional assignment than <code>||=</code>
      provides, for cases where you may be handling numbers or strings.
    </p>
    <div class='code'><pre><code>solipsism = <span class="literal">true</span> <span class="keyword">if</span> mind? <span class="keyword">and</span> <span class="keyword">not</span> world?

speed = <span class="number">0</span>
speed ?= <span class="number">15</span>

footprints = yeti ? <span class="string">"bear"</span>
</code></pre><pre><code><span class="keyword">var</span> footprints, solipsism, speed;

<span class="keyword">if</span> ((<span class="keyword">typeof</span> mind !== <span class="string">"undefined"</span> &amp;&amp; mind !== <span class="literal">null</span>) &amp;&amp; (<span class="keyword">typeof</span> world === <span class="string">"undefined"</span> || world === <span class="literal">null</span>)) {
  solipsism = <span class="literal">true</span>;
}

speed = <span class="number">0</span>;

<span class="keyword">if</span> (speed == <span class="literal">null</span>) {
  speed = <span class="number">15</span>;
}

footprints = <span class="keyword">typeof</span> yeti !== <span class="string">"undefined"</span> &amp;&amp; yeti !== <span class="literal">null</span> ? yeti : <span class="string">"bear"</span>;
</code></pre><script>window.example22 = "solipsism = true if mind? and not world?\n\nspeed = 0\nspeed ?= 15\n\nfootprints = yeti ? \"bear\"\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example22);'>load</div><div class='minibutton ok' onclick='javascript: var footprints, solipsism, speed;

if ((typeof mind !== "undefined" && mind !== null) && (typeof world === "undefined" || world === null)) {
  solipsism = true;
}

speed = 0;

if (speed == null) {
  speed = 15;
}

footprints = typeof yeti !== "undefined" && yeti !== null ? yeti : "bear";
;alert(footprints);'>run: footprints</div><br class='clear' /></div>
    <p>
      The accessor variant of the existential operator <code>?.</code> can be used to soak
      up null references in a chain of properties. Use it instead
      of the dot accessor <code>.</code> in cases where the base value may be <b>null</b>
      or <b>undefined</b>. If all of the properties exist then you'll get the expected
      result, if the chain is broken, <b>undefined</b> is returned instead of
      the <b>TypeError</b> that would be raised otherwise.
    </p>
    <div class='code'><pre><code>zip = lottery.drawWinner?().address?.zipcode
</code></pre><pre><code><span class="keyword">var</span> ref, zip;

zip = <span class="keyword">typeof</span> lottery.drawWinner === <span class="string">"function"</span> ? (ref = lottery.drawWinner().address) != <span class="literal">null</span> ? ref.zipcode : <span class="keyword">void</span> <span class="number">0</span> : <span class="keyword">void</span> <span class="number">0</span>;
</code></pre><script>window.example23 = "zip = lottery.drawWinner?().address?.zipcode\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example23);'>load</div><br class='clear' /></div>
    <p>
      Soaking up nulls is similar to Ruby's
      <a href="https://rubygems.org/gems/andand">andand gem</a>, and to the
      <a href="http://groovy.codehaus.org/Operators#Operators-SafeNavigationOperator%28%3F.%29">safe navigation operator</a>
      in Groovy.
    </p>

    <p>
      <span id="classes" class="bookmark"></span>
      <b class="header">Classes, Inheritance, and Super</b>
      JavaScript's prototypal inheritance has always been a bit of a
      brain-bender, with a whole family tree of libraries that provide a cleaner
      syntax for classical inheritance on top of JavaScript's prototypes:
      <a href="http://code.google.com/p/base2/">Base2</a>,
      <a href="http://prototypejs.org/">Prototype.js</a>,
      <a href="http://jsclass.jcoglan.com/">JS.Class</a>, etc.
      The libraries provide syntactic sugar, but the built-in inheritance would
      be completely usable if it weren't for a couple of small exceptions:
      it's awkward to call <b>super</b> (the prototype object's
      implementation of the current function), and it's awkward to correctly
      set the prototype chain.
    </p>
    <p>
      Instead of repetitively attaching functions to a prototype, CoffeeScript
      provides a basic <code>class</code> structure that allows you to name your class,
      set the superclass, assign prototypal properties, and define the constructor,
      in a single assignable expression.
    </p>
    <p>
      Constructor functions are named, to better support helpful stack traces.
      In the first class in the example below, <code>this.constructor.name is "Animal"</code>.
    </p>
    <div class='code'><pre><code><span class="class"><span class="keyword">class</span> <span class="title">Animal</span></span>
  <span class="attribute">constructor</span>: <span class="function"><span class="params">(<span class="property">@name</span>)</span> -&gt;</span>

  <span class="attribute">move</span>: <span class="function"><span class="params">(meters)</span> -&gt;</span>
    alert <span class="property">@name</span> + <span class="string">" moved <span class="subst">#{meters}</span>m."</span>

<span class="class"><span class="keyword">class</span> <span class="title">Snake</span> <span class="keyword">extends</span> <span class="title">Animal</span></span>
  <span class="attribute">move</span>:<span class="function"> -&gt;</span>
    alert <span class="string">"Slithering..."</span>
    <span class="keyword">super</span> <span class="number">5</span>

<span class="class"><span class="keyword">class</span> <span class="title">Horse</span> <span class="keyword">extends</span> <span class="title">Animal</span></span>
  <span class="attribute">move</span>:<span class="function"> -&gt;</span>
    alert <span class="string">"Galloping..."</span>
    <span class="keyword">super</span> <span class="number">45</span>

sam = <span class="keyword">new</span> Snake <span class="string">"Sammy the Python"</span>
tom = <span class="keyword">new</span> Horse <span class="string">"Tommy the Palomino"</span>

sam.move()
tom.move()
</code></pre><pre><code><span class="keyword">var</span> Animal, Horse, Snake, sam, tom,
  extend = <span class="function"><span class="keyword">function</span><span class="params">(child, parent)</span> {</span> <span class="keyword">for</span> (<span class="keyword">var</span> key <span class="keyword">in</span> parent) { <span class="keyword">if</span> (hasProp.call(parent, key)) child[key] = parent[key]; } <span class="function"><span class="keyword">function</span> <span class="title">ctor</span><span class="params">()</span> {</span> <span class="keyword">this</span>.constructor = child; } ctor.prototype = parent.prototype; child.prototype = <span class="keyword">new</span> ctor(); child.__super__ = parent.prototype; <span class="keyword">return</span> child; },
  hasProp = {}.hasOwnProperty;

Animal = (<span class="function"><span class="keyword">function</span><span class="params">()</span> {</span>
  <span class="function"><span class="keyword">function</span> <span class="title">Animal</span><span class="params">(name)</span> {</span>
    <span class="keyword">this</span>.name = name;
  }

  Animal.prototype.move = <span class="function"><span class="keyword">function</span><span class="params">(meters)</span> {</span>
    <span class="keyword">return</span> alert(<span class="keyword">this</span>.name + (<span class="string">" moved "</span> + meters + <span class="string">"m."</span>));
  };

  <span class="keyword">return</span> Animal;

})();

Snake = (<span class="function"><span class="keyword">function</span><span class="params">(superClass)</span> {</span>
  extend(Snake, superClass);

  <span class="function"><span class="keyword">function</span> <span class="title">Snake</span><span class="params">()</span> {</span>
    <span class="keyword">return</span> Snake.__super__.constructor.apply(<span class="keyword">this</span>, <span class="built_in">arguments</span>);
  }

  Snake.prototype.move = <span class="function"><span class="keyword">function</span><span class="params">()</span> {</span>
    alert(<span class="string">"Slithering..."</span>);
    <span class="keyword">return</span> Snake.__super__.move.call(<span class="keyword">this</span>, <span class="number">5</span>);
  };

  <span class="keyword">return</span> Snake;

})(Animal);

Horse = (<span class="function"><span class="keyword">function</span><span class="params">(superClass)</span> {</span>
  extend(Horse, superClass);

  <span class="function"><span class="keyword">function</span> <span class="title">Horse</span><span class="params">()</span> {</span>
    <span class="keyword">return</span> Horse.__super__.constructor.apply(<span class="keyword">this</span>, <span class="built_in">arguments</span>);
  }

  Horse.prototype.move = <span class="function"><span class="keyword">function</span><span class="params">()</span> {</span>
    alert(<span class="string">"Galloping..."</span>);
    <span class="keyword">return</span> Horse.__super__.move.call(<span class="keyword">this</span>, <span class="number">45</span>);
  };

  <span class="keyword">return</span> Horse;

})(Animal);

sam = <span class="keyword">new</span> Snake(<span class="string">"Sammy the Python"</span>);

tom = <span class="keyword">new</span> Horse(<span class="string">"Tommy the Palomino"</span>);

sam.move();

tom.move();
</code></pre><script>window.example24 = "class Animal\n  constructor: (@name) ->\n\n  move: (meters) ->\n    alert @name + \" moved #{meters}m.\"\n\nclass Snake extends Animal\n  move: ->\n    alert \"Slithering...\"\n    super 5\n\nclass Horse extends Animal\n  move: ->\n    alert \"Galloping...\"\n    super 45\n\nsam = new Snake \"Sammy the Python\"\ntom = new Horse \"Tommy the Palomino\"\n\nsam.move()\ntom.move()\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example24);'>load</div><div class='minibutton ok' onclick='javascript: var Animal, Horse, Snake, sam, tom,
  extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  hasProp = {}.hasOwnProperty;

Animal = (function() {
  function Animal(name) {
    this.name = name;
  }

  Animal.prototype.move = function(meters) {
    return alert(this.name + (" moved " + meters + "m."));
  };

  return Animal;

})();

Snake = (function(superClass) {
  extend(Snake, superClass);

  function Snake() {
    return Snake.__super__.constructor.apply(this, arguments);
  }

  Snake.prototype.move = function() {
    alert("Slithering...");
    return Snake.__super__.move.call(this, 5);
  };

  return Snake;

})(Animal);

Horse = (function(superClass) {
  extend(Horse, superClass);

  function Horse() {
    return Horse.__super__.constructor.apply(this, arguments);
  }

  Horse.prototype.move = function() {
    alert("Galloping...");
    return Horse.__super__.move.call(this, 45);
  };

  return Horse;

})(Animal);

sam = new Snake("Sammy the Python");

tom = new Horse("Tommy the Palomino");

sam.move();

tom.move();
;'>run</div><br class='clear' /></div>
    <p>
      If structuring your prototypes classically isn't your cup of tea, CoffeeScript
      provides a couple of lower-level conveniences. The <code>extends</code> operator
      helps with proper prototype setup, and can be used to create an inheritance
      chain between any pair of constructor functions; <code>::</code> gives you
      quick access to an object's prototype; and <code>super()</code>
      is converted into a call against the immediate ancestor's method of the same name.
    </p>
    <div class='code'><pre><code><span class="attribute">String</span>::<span class="function"><span class="title">dasherize</span> = -&gt;</span>
  <span class="keyword">this</span>.replace <span class="regexp">/_/g</span>, <span class="string">"-"</span>
</code></pre><pre><code><span class="built_in">String</span>.prototype.dasherize = <span class="function"><span class="keyword">function</span><span class="params">()</span> {</span>
  <span class="keyword">return</span> <span class="keyword">this</span>.replace(<span class="regexp">/_/g</span>, <span class="string">"-"</span>);
};
</code></pre><script>window.example25 = "String::dasherize = ->\n  this.replace /_/g, \"-\"\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example25);'>load</div><div class='minibutton ok' onclick='javascript: String.prototype.dasherize = function() {
  return this.replace(/_/g, "-");
};
;alert("one_two".dasherize());'>run: "one_two".dasherize()</div><br class='clear' /></div>
    <p>
      Finally, class definitions are blocks of executable code, which make for interesting
      metaprogramming possibilities. Because in the context of a class definition,
      <code>this</code> is the class object itself (the constructor function), you
      can assign static properties by using <br /><code>@property: value</code>, and call
      functions defined in parent classes: <code>@attr 'title', type: 'text'</code>
    </p>

    <p>
      <span id="destructuring" class="bookmark"></span>
      <b class="header">Destructuring Assignment</b>
      Just like JavaScript (since ES2015), CoffeeScript has destructuring assignment
      syntax. When you assign an array or object literal to a value, CoffeeScript
      breaks up and matches both sides against each other, assigning the values
      on the right to the variables on the left. In the simplest case, it can be
      used for parallel assignment:
    </p>
    <div class='code'><pre><code>theBait   = <span class="number">1000</span>
theSwitch = <span class="number">0</span>

[theBait, theSwitch] = [theSwitch, theBait]
</code></pre><pre><code><span class="keyword">var</span> ref, theBait, theSwitch;

theBait = <span class="number">1000</span>;

theSwitch = <span class="number">0</span>;

ref = [theSwitch, theBait], theBait = ref[<span class="number">0</span>], theSwitch = ref[<span class="number">1</span>];
</code></pre><script>window.example26 = "theBait   = 1000\ntheSwitch = 0\n\n[theBait, theSwitch] = [theSwitch, theBait]\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example26);'>load</div><div class='minibutton ok' onclick='javascript: var ref, theBait, theSwitch;

theBait = 1000;

theSwitch = 0;

ref = [theSwitch, theBait], theBait = ref[0], theSwitch = ref[1];
;alert(theBait);'>run: theBait</div><br class='clear' /></div>
    <p>
      But it's also helpful for dealing with functions that return multiple
      values.
    </p>
    <div class='code'><pre><code><span class="function"><span class="title">weatherReport</span> = <span class="params">(location)</span> -&gt;</span>
  <span class="comment"># Make an Ajax request to fetch the weather...</span>
  [location, <span class="number">72</span>, <span class="string">"Mostly Sunny"</span>]

[city, temp, forecast] = weatherReport <span class="string">"Berkeley, CA"</span>
</code></pre><pre><code><span class="keyword">var</span> city, forecast, ref, temp, weatherReport;

weatherReport = <span class="function"><span class="keyword">function</span><span class="params">(location)</span> {</span>
  <span class="keyword">return</span> [location, <span class="number">72</span>, <span class="string">"Mostly Sunny"</span>];
};

ref = weatherReport(<span class="string">"Berkeley, CA"</span>), city = ref[<span class="number">0</span>], temp = ref[<span class="number">1</span>], forecast = ref[<span class="number">2</span>];
</code></pre><script>window.example27 = "weatherReport = (location) ->\n  # Make an Ajax request to fetch the weather...\n  [location, 72, \"Mostly Sunny\"]\n\n[city, temp, forecast] = weatherReport \"Berkeley, CA\"\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example27);'>load</div><div class='minibutton ok' onclick='javascript: var city, forecast, ref, temp, weatherReport;

weatherReport = function(location) {
  return [location, 72, "Mostly Sunny"];
};

ref = weatherReport("Berkeley, CA"), city = ref[0], temp = ref[1], forecast = ref[2];
;alert(forecast);'>run: forecast</div><br class='clear' /></div>
    <p>
      Destructuring assignment can be used with any depth of array and object nesting,
      to help pull out deeply nested properties.
    </p>
    <div class='code'><pre><code>futurists =
  <span class="attribute">sculptor</span>: <span class="string">"Umberto Boccioni"</span>
  <span class="attribute">painter</span>:  <span class="string">"Vladimir Burliuk"</span>
  <span class="attribute">poet</span>:
    <span class="attribute">name</span>:   <span class="string">"F.T. Marinetti"</span>
    <span class="attribute">address</span>: [
      <span class="string">"Via Roma 42R"</span>
      <span class="string">"Bellagio, Italy 22021"</span>
    ]

{<span class="attribute">poet</span>: {name, <span class="attribute">address</span>: [street, city]}} = futurists
</code></pre><pre><code><span class="keyword">var</span> city, futurists, name, ref, ref1, street;

futurists = {
  sculptor: <span class="string">"Umberto Boccioni"</span>,
  painter: <span class="string">"Vladimir Burliuk"</span>,
  poet: {
    name: <span class="string">"F.T. Marinetti"</span>,
    address: [<span class="string">"Via Roma 42R"</span>, <span class="string">"Bellagio, Italy 22021"</span>]
  }
};

ref = futurists.poet, name = ref.name, (ref1 = ref.address, street = ref1[<span class="number">0</span>], city = ref1[<span class="number">1</span>]);
</code></pre><script>window.example28 = "futurists =\n  sculptor: \"Umberto Boccioni\"\n  painter:  \"Vladimir Burliuk\"\n  poet:\n    name:   \"F.T. Marinetti\"\n    address: [\n      \"Via Roma 42R\"\n      \"Bellagio, Italy 22021\"\n    ]\n\n{poet: {name, address: [street, city]}} = futurists\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example28);'>load</div><div class='minibutton ok' onclick='javascript: var city, futurists, name, ref, ref1, street;

futurists = {
  sculptor: "Umberto Boccioni",
  painter: "Vladimir Burliuk",
  poet: {
    name: "F.T. Marinetti",
    address: ["Via Roma 42R", "Bellagio, Italy 22021"]
  }
};

ref = futurists.poet, name = ref.name, (ref1 = ref.address, street = ref1[0], city = ref1[1]);
;alert(name + "-" + street);'>run: name + "-" + street</div><br class='clear' /></div>
    <p>
      Destructuring assignment can even be combined with splats.
    </p>
    <div class='code'><pre><code>tag = <span class="string">"&lt;impossible&gt;"</span>

[open, contents..., close] = tag.split(<span class="string">""</span>)
</code></pre><pre><code><span class="keyword">var</span> close, contents, i, open, ref, tag,
  slice = [].slice;

tag = <span class="string">"&lt;impossible&gt;"</span>;

ref = tag.split(<span class="string">""</span>), open = ref[<span class="number">0</span>], contents = <span class="number">3</span> &lt;= ref.length ? slice.call(ref, <span class="number">1</span>, i = ref.length - <span class="number">1</span>) : (i = <span class="number">1</span>, []), close = ref[i++];
</code></pre><script>window.example29 = "tag = \"<impossible>\"\n\n[open, contents..., close] = tag.split(\"\")\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example29);'>load</div><div class='minibutton ok' onclick='javascript: var close, contents, i, open, ref, tag,
  slice = [].slice;

tag = "<impossible>";

ref = tag.split(""), open = ref[0], contents = 3 <= ref.length ? slice.call(ref, 1, i = ref.length - 1) : (i = 1, []), close = ref[i++];
;alert(contents.join(""));'>run: contents.join("")</div><br class='clear' /></div>
    <p>
      Expansion can be used to retrieve elements from the end of an array without having to assign the rest of its values. It works in function parameter lists as well.
    </p>
    <div class='code'><pre><code>text = <span class="string">"Every literary critic believes he will
        outwit history and have the last word"</span>

[first, ..., last] = text.split <span class="string">" "</span>
</code></pre><pre><code><span class="keyword">var</span> first, last, ref, text;

text = <span class="string">"Every literary critic believes he will outwit history and have the last word"</span>;

ref = text.split(<span class="string">" "</span>), first = ref[<span class="number">0</span>], last = ref[ref.length - <span class="number">1</span>];
</code></pre><script>window.example30 = "text = \"Every literary critic believes he will\n        outwit history and have the last word\"\n\n[first, ..., last] = text.split \" \"\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example30);'>load</div><div class='minibutton ok' onclick='javascript: var first, last, ref, text;

text = "Every literary critic believes he will outwit history and have the last word";

ref = text.split(" "), first = ref[0], last = ref[ref.length - 1];
;alert(first + " " + last);'>run: first + " " + last</div><br class='clear' /></div>
    <p>
      Destructuring assignment is also useful when combined with class constructors
      to assign properties to your instance from an options object passed to the constructor.
    </p>
    <div class='code'><pre><code><span class="class"><span class="keyword">class</span> <span class="title">Person</span></span>
  <span class="attribute">constructor</span>: <span class="function"><span class="params">(options)</span> -&gt;</span>
    {<span class="property">@name</span>, <span class="property">@age</span>, <span class="property">@height</span> = <span class="string">'average'</span>} = options

tim = <span class="keyword">new</span> Person <span class="attribute">name</span>: <span class="string">'Tim'</span>, <span class="attribute">age</span>: <span class="number">4</span>
</code></pre><pre><code><span class="keyword">var</span> Person, tim;

Person = (<span class="function"><span class="keyword">function</span><span class="params">()</span> {</span>
  <span class="function"><span class="keyword">function</span> <span class="title">Person</span><span class="params">(options)</span> {</span>
    <span class="keyword">var</span> ref;
    <span class="keyword">this</span>.name = options.name, <span class="keyword">this</span>.age = options.age, <span class="keyword">this</span>.height = (ref = options.height) != <span class="literal">null</span> ? ref : <span class="string">'average'</span>;
  }

  <span class="keyword">return</span> Person;

})();

tim = <span class="keyword">new</span> Person({
  name: <span class="string">'Tim'</span>,
  age: <span class="number">4</span>
});
</code></pre><script>window.example31 = "class Person\n  constructor: (options) ->\n    {@name, @age, @height = 'average'} = options\n\ntim = new Person name: 'Tim', age: 4\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example31);'>load</div><div class='minibutton ok' onclick='javascript: var Person, tim;

Person = (function() {
  function Person(options) {
    var ref;
    this.name = options.name, this.age = options.age, this.height = (ref = options.height) != null ? ref : 'average';
  }

  return Person;

})();

tim = new Person({
  name: 'Tim',
  age: 4
});
;alert(tim.age + " " + tim.height);'>run: tim.age + " " + tim.height</div><br class='clear' /></div>
    <p>
      The above example also demonstrates that if properties are missing in the
      destructured object or array, you can, just like in JavaScript, provide
      defaults. The difference with JavaScript is that CoffeeScript, as always,
      treats both null and undefined the same.
    </p>

    <p>
      <span id="fat-arrow" class="bookmark"></span>
      <b class="header">Bound Functions, Generator Functions</b>
      In JavaScript, the <code>this</code> keyword is dynamically scoped to mean the
      object that the current function is attached to. If you pass a function as
      a callback or attach it to a different object, the original value of <code>this</code>
      will be lost. If you're not familiar with this behavior,
      <a href="http://www.digital-web.com/articles/scope_in_javascript/">this Digital Web article</a>
      gives a good overview of the quirks.
    </p>
    <p>
      The fat arrow <code>=&gt;</code> can be used to both define a function, and to bind
      it to the current value of <code>this</code>, right on the spot. This is helpful
      when using callback-based libraries like Prototype or jQuery, for creating
      iterator functions to pass to <code>each</code>, or event-handler functions
      to use with <code>on</code>. Functions created with the fat arrow are able to access
      properties of the <code>this</code> where they're defined.
    </p>
    <div class='code'><pre><code><span class="function"><span class="title">Account</span> = <span class="params">(customer, cart)</span> -&gt;</span>
  <span class="property">@customer</span> = customer
  <span class="property">@cart</span> = cart

  $<span class="function"><span class="params">(<span class="string">'.shopping_cart'</span>)</span>.<span class="title">on</span> '<span class="title">click</span>', <span class="params">(event)</span> =&gt;</span>
    <span class="property">@customer</span>.purchase <span class="property">@cart</span></code></pre><pre><code><span class="keyword">var</span> Account;

Account = <span class="function"><span class="keyword">function</span><span class="params">(customer, cart)</span> {</span>
  <span class="keyword">this</span>.customer = customer;
  <span class="keyword">this</span>.cart = cart;
  <span class="keyword">return</span> $(<span class="string">'.shopping_cart'</span>).on(<span class="string">'click'</span>, (<span class="function"><span class="keyword">function</span><span class="params">(_this)</span> {</span>
    <span class="keyword">return</span> <span class="function"><span class="keyword">function</span><span class="params">(event)</span> {</span>
      <span class="keyword">return</span> _this.customer.purchase(_this.cart);
    };
  })(<span class="keyword">this</span>));
};
</code></pre><script>window.example32 = "Account = (customer, cart) ->\n  @customer = customer\n  @cart = cart\n\n  $('.shopping_cart').on 'click', (event) =>\n    @customer.purchase @cart"</script><div class='minibutton load' onclick='javascript: loadConsole(example32);'>load</div><br class='clear' /></div>
    <p>
      If we had used <code>-&gt;</code> in the callback above, <code>@customer</code> would
      have referred to the undefined "customer" property of the DOM element,
      and trying to call <code>purchase()</code> on it would have raised an exception.
    </p>
    <p>
      When used in a class definition, methods declared with the fat arrow will
      be automatically bound to each instance of the class when the instance is
      constructed.
    </p>
    <p>
      CoffeeScript functions also support
      <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*">ES6 generator functions</a>
      through the <code>yield</code> keyword. There's no <code>function*(){}</code>
      nonsense &mdash; a generator in CoffeeScript is simply a function that yields.
    </p>
    <div class='code'><pre><code><span class="function"><span class="title">perfectSquares</span> = -&gt;</span>
  num = <span class="number">0</span>
  <span class="keyword">loop</span>
    num += <span class="number">1</span>
    yield num * num
  <span class="keyword">return</span>

<span class="built_in">window</span>.ps <span class="keyword">or</span>= perfectSquares()</code></pre><pre><code><span class="keyword">var</span> perfectSquares;

perfectSquares = <span class="function"><span class="keyword">function</span>*<span class="params">()</span> {</span>
  <span class="keyword">var</span> num;
  num = <span class="number">0</span>;
  <span class="keyword">while</span> (<span class="literal">true</span>) {
    num += <span class="number">1</span>;
    (<span class="keyword">yield</span> num * num);
  }
};

window.ps || (window.ps = perfectSquares());
</code></pre><script>window.example33 = "perfectSquares = ->\n  num = 0\n  loop\n    num += 1\n    yield num * num\n  return\n\nwindow.ps or= perfectSquares()"</script><div class='minibutton load' onclick='javascript: loadConsole(example33);'>load</div><div class='minibutton ok' onclick='javascript: var perfectSquares;

perfectSquares = function*() {
  var num;
  num = 0;
  while (true) {
    num += 1;
    (yield num * num);
  }
};

window.ps || (window.ps = perfectSquares());
;alert(ps.next().value);'>run: ps.next().value</div><br class='clear' /></div>
    <p>
      <code>yield*</code> is called <code>yield from</code>, and <code>yield return</code>
      may be used if you need to force a generator that doesn't yield.
    </p>

    <p>
      <span id="embedded" class="bookmark"></span>
      <b class="header">Embedded JavaScript</b>
      Hopefully, you'll never need to use it, but if you ever need to intersperse
      snippets of JavaScript within your CoffeeScript, you can
      use backticks to pass it straight through.
    </p>
    <div class='code'><pre><code>hi = `<span class="javascript"><span class="function"><span class="keyword">function</span><span class="params">()</span> {</span>
  <span class="keyword">return</span> [document.title, <span class="string">"Hello JavaScript"</span>].join(<span class="string">": "</span>);
}</span>`
</code></pre><pre><code><span class="keyword">var</span> hi;

hi = <span class="function"><span class="keyword">function</span><span class="params">()</span> {</span>
  <span class="keyword">return</span> [document.title, <span class="string">"Hello JavaScript"</span>].join(<span class="string">": "</span>);
};
</code></pre><script>window.example34 = "hi = `function() {\n  return [document.title, \"Hello JavaScript\"].join(\": \");\n}`\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example34);'>load</div><div class='minibutton ok' onclick='javascript: var hi;

hi = function() {
  return [document.title, "Hello JavaScript"].join(": ");
};
;alert(hi());'>run: hi()</div><br class='clear' /></div>

    <p>
      <span id="switch" class="bookmark"></span>
      <b class="header">Switch/When/Else</b>
      <b>Switch</b> statements in JavaScript are a bit awkward. You need to
      remember to <b>break</b> at the end of every <b>case</b> statement to
      avoid accidentally falling through to the default case.
      CoffeeScript prevents accidental fall-through, and can convert the <code>switch</code>
      into a returnable, assignable expression. The format is: <code>switch</code> condition,
      <code>when</code> clauses, <code>else</code> the default case.
    </p>
    <p>
      As in Ruby, <b>switch</b> statements in CoffeeScript can take multiple
      values for each <b>when</b> clause. If any of the values match, the clause
      runs.
    </p>
    <div class='code'><pre><code><span class="keyword">switch</span> day
  <span class="keyword">when</span> <span class="string">"Mon"</span> <span class="keyword">then</span> go work
  <span class="keyword">when</span> <span class="string">"Tue"</span> <span class="keyword">then</span> go relax
  <span class="keyword">when</span> <span class="string">"Thu"</span> <span class="keyword">then</span> go iceFishing
  <span class="keyword">when</span> <span class="string">"Fri"</span>, <span class="string">"Sat"</span>
    <span class="keyword">if</span> day <span class="keyword">is</span> bingoDay
      go bingo
      go dancing
  <span class="keyword">when</span> <span class="string">"Sun"</span> <span class="keyword">then</span> go church
  <span class="keyword">else</span> go work</code></pre><pre><code><span class="keyword">switch</span> (day) {
  <span class="keyword">case</span> <span class="string">"Mon"</span>:
    go(work);
    <span class="keyword">break</span>;
  <span class="keyword">case</span> <span class="string">"Tue"</span>:
    go(relax);
    <span class="keyword">break</span>;
  <span class="keyword">case</span> <span class="string">"Thu"</span>:
    go(iceFishing);
    <span class="keyword">break</span>;
  <span class="keyword">case</span> <span class="string">"Fri"</span>:
  <span class="keyword">case</span> <span class="string">"Sat"</span>:
    <span class="keyword">if</span> (day === bingoDay) {
      go(bingo);
      go(dancing);
    }
    <span class="keyword">break</span>;
  <span class="keyword">case</span> <span class="string">"Sun"</span>:
    go(church);
    <span class="keyword">break</span>;
  <span class="keyword">default</span>:
    go(work);
}
</code></pre><script>window.example35 = "switch day\n  when \"Mon\" then go work\n  when \"Tue\" then go relax\n  when \"Thu\" then go iceFishing\n  when \"Fri\", \"Sat\"\n    if day is bingoDay\n      go bingo\n      go dancing\n  when \"Sun\" then go church\n  else go work"</script><div class='minibutton load' onclick='javascript: loadConsole(example35);'>load</div><br class='clear' /></div>

    <p>
      Switch statements can also be used without a control expression, turning them in to a cleaner alternative to if/else chains.
    </p>
    <div class='code'><pre><code>score = <span class="number">76</span>
grade = <span class="keyword">switch</span>
  <span class="keyword">when</span> score &lt; <span class="number">60</span> <span class="keyword">then</span> <span class="string">'F'</span>
  <span class="keyword">when</span> score &lt; <span class="number">70</span> <span class="keyword">then</span> <span class="string">'D'</span>
  <span class="keyword">when</span> score &lt; <span class="number">80</span> <span class="keyword">then</span> <span class="string">'C'</span>
  <span class="keyword">when</span> score &lt; <span class="number">90</span> <span class="keyword">then</span> <span class="string">'B'</span>
  <span class="keyword">else</span> <span class="string">'A'</span>
<span class="comment"># grade == 'C'</span>
</code></pre><pre><code><span class="keyword">var</span> grade, score;

score = <span class="number">76</span>;

grade = (<span class="function"><span class="keyword">function</span><span class="params">()</span> {</span>
  <span class="keyword">switch</span> (<span class="literal">false</span>) {
    <span class="keyword">case</span> !(score &lt; <span class="number">60</span>):
      <span class="keyword">return</span> <span class="string">'F'</span>;
    <span class="keyword">case</span> !(score &lt; <span class="number">70</span>):
      <span class="keyword">return</span> <span class="string">'D'</span>;
    <span class="keyword">case</span> !(score &lt; <span class="number">80</span>):
      <span class="keyword">return</span> <span class="string">'C'</span>;
    <span class="keyword">case</span> !(score &lt; <span class="number">90</span>):
      <span class="keyword">return</span> <span class="string">'B'</span>;
    <span class="keyword">default</span>:
      <span class="keyword">return</span> <span class="string">'A'</span>;
  }
})();
</code></pre><script>window.example36 = "score = 76\ngrade = switch\n  when score < 60 then 'F'\n  when score < 70 then 'D'\n  when score < 80 then 'C'\n  when score < 90 then 'B'\n  else 'A'\n# grade == 'C'\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example36);'>load</div><br class='clear' /></div>

    <p>
      <span id="try" class="bookmark"></span>
      <b class="header">Try/Catch/Finally</b>
      Try-expressions have the same semantics as try-statements in JavaScript,
      though in CoffeeScript, you may omit <em>both</em> the catch and finally
      parts. The catch part may also omit the error parameter if it is not needed.
    </p>
    <div class='code'><pre><code><span class="keyword">try</span>
  allHellBreaksLoose()
  catsAndDogsLivingTogether()
<span class="keyword">catch</span> error
  <span class="built_in">print</span> error
<span class="keyword">finally</span>
  cleanUp()
</code></pre><pre><code><span class="keyword">var</span> error, error1;

<span class="keyword">try</span> {
  allHellBreaksLoose();
  catsAndDogsLivingTogether();
} <span class="keyword">catch</span> (error1) {
  error = error1;
  print(error);
} <span class="keyword">finally</span> {
  cleanUp();
}
</code></pre><script>window.example37 = "try\n  allHellBreaksLoose()\n  catsAndDogsLivingTogether()\ncatch error\n  print error\nfinally\n  cleanUp()\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example37);'>load</div><br class='clear' /></div>

    <p>
      <span id="comparisons" class="bookmark"></span>
      <b class="header">Chained Comparisons</b>
      CoffeeScript borrows
      <a href="http://docs.python.org/reference/expressions.html#notin">chained comparisons</a>
      from Python &mdash; making it easy to test if a value falls within a
      certain range.
    </p>
    <div class='code'><pre><code>cholesterol = <span class="number">127</span>

healthy = <span class="number">200</span> &gt; cholesterol &gt; <span class="number">60</span>
</code></pre><pre><code><span class="keyword">var</span> cholesterol, healthy;

cholesterol = <span class="number">127</span>;

healthy = (<span class="number">200</span> &gt; cholesterol &amp;&amp; cholesterol &gt; <span class="number">60</span>);
</code></pre><script>window.example38 = "cholesterol = 127\n\nhealthy = 200 > cholesterol > 60\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example38);'>load</div><div class='minibutton ok' onclick='javascript: var cholesterol, healthy;

cholesterol = 127;

healthy = (200 > cholesterol && cholesterol > 60);
;alert(healthy);'>run: healthy</div><br class='clear' /></div>

    <p>
      <span id="strings" class="bookmark"></span>
      <b class="header">String Interpolation, Block Strings, and Block Comments</b>
      Ruby-style string interpolation is included in CoffeeScript. Double-quoted
      strings allow for interpolated values, using <code>#{ ... }</code>,
      and single-quoted strings are literal. You may even use interpolation in
      object keys.
    </p>
    <div class='code'><pre><code>author = <span class="string">"Wittgenstein"</span>
quote  = <span class="string">"A picture is a fact. -- <span class="subst">#{ author }</span>"</span>

sentence = <span class="string">"<span class="subst">#{ <span class="number">22</span> / <span class="number">7</span> }</span> is a decent approximation of π"</span>
</code></pre><pre><code><span class="keyword">var</span> author, quote, sentence;

author = <span class="string">"Wittgenstein"</span>;

quote = <span class="string">"A picture is a fact. -- "</span> + author;

sentence = (<span class="number">22</span> / <span class="number">7</span>) + <span class="string">" is a decent approximation of π"</span>;
</code></pre><script>window.example39 = "author = \"Wittgenstein\"\nquote  = \"A picture is a fact. -- #{ author }\"\n\nsentence = \"#{ 22 / 7 } is a decent approximation of π\"\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example39);'>load</div><div class='minibutton ok' onclick='javascript: var author, quote, sentence;

author = "Wittgenstein";

quote = "A picture is a fact. -- " + author;

sentence = (22 / 7) + " is a decent approximation of π";
;alert(sentence);'>run: sentence</div><br class='clear' /></div>
    <p>
      Multiline strings are allowed in CoffeeScript. Lines are joined by a single space unless they end with a backslash. Indentation is ignored.
    </p>
    <div class='code'><pre><code>mobyDick = <span class="string">"Call me Ishmael. Some years ago --
  never mind how long precisely -- having little
  or no money in my purse, and nothing particular
  to interest me on shore, I thought I would sail
  about a little and see the watery part of the
  world..."</span>
</code></pre><pre><code><span class="keyword">var</span> mobyDick;

mobyDick = <span class="string">"Call me Ishmael. Some years ago -- never mind how long precisely -- having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world..."</span>;
</code></pre><script>window.example40 = "mobyDick = \"Call me Ishmael. Some years ago --\n  never mind how long precisely -- having little\n  or no money in my purse, and nothing particular\n  to interest me on shore, I thought I would sail\n  about a little and see the watery part of the\n  world...\"\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example40);'>load</div><div class='minibutton ok' onclick='javascript: var mobyDick;

mobyDick = "Call me Ishmael. Some years ago -- never mind how long precisely -- having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world...";
;alert(mobyDick);'>run: mobyDick</div><br class='clear' /></div>
    <p>
      Block strings can be used to hold formatted or indentation-sensitive text
      (or, if you just don't feel like escaping quotes and apostrophes). The
      indentation level that begins the block is maintained throughout, so
      you can keep it all aligned with the body of your code.
    </p>
    <div class='code'><pre><code>html = <span class="string">"""
       &lt;strong&gt;
         cup of coffeescript
       &lt;/strong&gt;
       """</span>
</code></pre><pre><code><span class="keyword">var</span> html;

html = <span class="string">"&lt;strong&gt;\n  cup of coffeescript\n&lt;/strong&gt;"</span>;
</code></pre><script>window.example41 = "html = \"\"\"\n       <strong>\n         cup of coffeescript\n       </strong>\n       \"\"\"\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example41);'>load</div><div class='minibutton ok' onclick='javascript: var html;

html = "<strong>\n  cup of coffeescript\n</strong>";
;alert(html);'>run: html</div><br class='clear' /></div>
    <p>
      Double-quoted block strings, like other double-quoted strings, allow interpolation.
    </p>
    <p>
      Sometimes you'd like to pass a block comment through to the generated
      JavaScript. For example, when you need to embed a licensing header at
      the top of a file. Block comments, which mirror the syntax for block strings,
      are preserved in the generated code.
    </p>
    <div class='code'><pre><code><span class="comment">###
SkinnyMochaHalfCaffScript Compiler v1.0
Released under the MIT License
###</span>


</code></pre><pre><code>
<span class="comment">/*
SkinnyMochaHalfCaffScript Compiler v1.0
Released under the MIT License
 */</span>

</code></pre><script>window.example42 = "###\nSkinnyMochaHalfCaffScript Compiler v1.0\nReleased under the MIT License\n###\n\n\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example42);'>load</div><br class='clear' /></div>

    <p>
      <span id="regexes" class="bookmark"></span>
      <b class="header">Block Regular Expressions</b>
      Similar to block strings and comments, CoffeeScript supports block regexes &mdash;
      extended regular expressions that ignore internal whitespace and can contain
      comments and interpolation. Modeled after Perl's <code>/x</code> modifier, CoffeeScript's
      block regexes are delimited by <code>///</code> and go a long way towards making complex
      regular expressions readable. To quote from the CoffeeScript source:
    </p>
    <div class='code'><pre><code>OPERATOR = <span class="regexp">/// ^ (
  ?: [-=]&gt;             <span class="comment"># function</span>
   | [-+*/%&lt;&gt;&amp;|^!?=]=  <span class="comment"># compound assign / compare</span>
   | &gt;&gt;&gt;=?             <span class="comment"># zero-fill right shift</span>
   | ([-+:])\1         <span class="comment"># doubles</span>
   | ([&amp;|&lt;&gt;])\2=?      <span class="comment"># logic / shift</span>
   | \?\.              <span class="comment"># soak access</span>
   | \.{2,3}           <span class="comment"># range or splat</span>
) ///</span>
</code></pre><pre><code><span class="keyword">var</span> OPERATOR;

OPERATOR = <span class="regexp">/^(?:[-=]&gt;|[-+*\/%&lt;&gt;&amp;|^!?=]=|&gt;&gt;&gt;=?|([-+:])\1|([&amp;|&lt;&gt;])\2=?|\?\.|\.{2,3})/</span>;
</code></pre><script>window.example43 = "OPERATOR = /// ^ (\n  ?: [-=]>             # function\n   | [-+*/%<>&|^!?=]=  # compound assign / compare\n   | >>>=?             # zero-fill right shift\n   | ([-+:])\\1         # doubles\n   | ([&|<>])\\2=?      # logic / shift\n   | \\?\\.              # soak access\n   | \\.{2,3}           # range or splat\n) ///\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example43);'>load</div><br class='clear' /></div>


    <h2>
      <span id="cake" class="bookmark"></span>
      Cake, and Cakefiles
    </h2>

    <p>
      CoffeeScript includes a (very) simple build system similar to
      <a href="http://www.gnu.org/software/make/">Make</a> and
      <a href="http://rake.rubyforge.org/">Rake</a>. Naturally,
      it's called Cake, and is used for the tasks that build and test the CoffeeScript
      language itself. Tasks are defined in a file named <code>Cakefile</code>, and
      can be invoked by running <code>cake [task]</code> from within the directory.
      To print a list of all the tasks and options, just type <code>cake</code>.
    </p>

    <p>
      Task definitions are written in CoffeeScript, so you can put arbitrary code
      in your Cakefile. Define a task with a name, a long description, and the
      function to invoke when the task is run. If your task takes a command-line
      option, you can define the option with short and long flags, and it will
      be made available in the <code>options</code> object. Here's a task that uses
      the Node.js API to rebuild CoffeeScript's parser:
    </p>
    <div class='code'><pre><code>fs = <span class="built_in">require</span> <span class="string">'fs'</span>

option <span class="string">'-o'</span>, <span class="string">'--output [DIR]'</span>, <span class="string">'directory for compiled code'</span>

task <span class="string">'build:parser'</span>, <span class="string">'rebuild the Jison parser'</span>, <span class="function"><span class="params">(options)</span> -&gt;</span>
  <span class="built_in">require</span> <span class="string">'jison'</span>
  code = <span class="built_in">require</span>(<span class="string">'./lib/grammar'</span>).parser.generate()
  dir  = options.output <span class="keyword">or</span> <span class="string">'lib'</span>
  fs.writeFile <span class="string">"<span class="subst">#{dir}</span>/parser.js"</span>, code</code></pre><pre><code><span class="keyword">var</span> fs;

fs = <span class="built_in">require</span>(<span class="string">'fs'</span>);

option(<span class="string">'-o'</span>, <span class="string">'--output [DIR]'</span>, <span class="string">'directory for compiled code'</span>);

task(<span class="string">'build:parser'</span>, <span class="string">'rebuild the Jison parser'</span>, <span class="function"><span class="keyword">function</span><span class="params">(options)</span> {</span>
  <span class="keyword">var</span> code, dir;
  <span class="built_in">require</span>(<span class="string">'jison'</span>);
  code = <span class="built_in">require</span>(<span class="string">'./lib/grammar'</span>).parser.generate();
  dir = options.output || <span class="string">'lib'</span>;
  <span class="keyword">return</span> fs.writeFile(dir + <span class="string">"/parser.js"</span>, code);
});
</code></pre><script>window.example44 = "fs = require 'fs'\n\noption '-o', '--output [DIR]', 'directory for compiled code'\n\ntask 'build:parser', 'rebuild the Jison parser', (options) ->\n  require 'jison'\n  code = require('./lib/grammar').parser.generate()\n  dir  = options.output or 'lib'\n  fs.writeFile \"#{dir}/parser.js\", code"</script><div class='minibutton load' onclick='javascript: loadConsole(example44);'>load</div><br class='clear' /></div>
    <p>
      If you need to invoke one task before another &mdash; for example, running
      <code>build</code> before <code>test</code>, you can use the <code>invoke</code> function:
      <code>invoke 'build'</code>. Cake tasks are a minimal way to expose your
      CoffeeScript functions to the command line, so
      <a href="documentation/docs/cake.html">don't expect any fanciness built-in</a>.
      If you need dependencies, or async callbacks, it's best to put them in your
      code itself &mdash; not the cake task.
    </p>

    <h2>
      <span id="source-maps" class="bookmark"></span>
      Source Maps
    </h2>

    <p>
      CoffeeScript 1.6.1 and above include support for generating source maps,
      a way to tell your JavaScript engine what part of your CoffeeScript
      program matches up with the code being evaluated. Browsers that support it
      can automatically use source maps to show your original source code
      in the debugger. To generate source maps alongside your JavaScript files,
      pass the <code>--map</code> or <code>-m</code> flag to the compiler.
    </p>

    <p>
      For a full introduction to source maps, how they work, and how to hook
      them up in your browser, read the
      <a href="http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/">HTML5 Tutorial</a>.
    </p>

    <h2>
      <span id="scripts" class="bookmark"></span>
      "text/coffeescript" Script Tags
    </h2>

    <p>
      While it's not recommended for serious use, CoffeeScripts may be included
      directly within the browser using <code>&lt;script type="text/coffeescript"&gt;</code>
      tags. The source includes a compressed and minified version of the compiler
      (<a href="extras/coffee-script.js">Download current version here, 39k when gzipped</a>)
      as <code>extras/coffee-script.js</code>. Include this file on a page with
      inline CoffeeScript tags, and it will compile and evaluate them in order.
    </p>

    <p>
      In fact, the little bit of glue script that runs "Try CoffeeScript" above,
      as well as the jQuery for the menu, is implemented in just this way.
      View source and look at the bottom of the page to see the example.
      Including the script also gives you access to <code>CoffeeScript.compile()</code>
      so you can pop open Firebug and try compiling some strings.
    </p>

    <p>
      The usual caveats about CoffeeScript apply &mdash; your inline scripts will
      run within a closure wrapper, so if you want to expose global variables or
      functions, attach them to the <code>window</code> object.
    </p>

    <h2>
      <span id="resources" class="bookmark"></span>
      Books
    </h2>

    <p>
      There are a number of excellent resources to help you get
      started with CoffeeScript, some of which are freely available online.
    </p>

    <ul>
      <li>
        <a href="http://arcturo.github.com/library/coffeescript/">The Little Book on CoffeeScript</a>
        is a brief 5-chapter introduction to CoffeeScript, written with great
        clarity and precision by
        <a href="http://alexmaccaw.co.uk/">Alex MacCaw</a>.
      </li>
      <li>
        <a href="http://autotelicum.github.com/Smooth-CoffeeScript/">Smooth CoffeeScript</a>
        is a reimagination of the excellent book
        <a href="http://eloquentjavascript.net/">Eloquent JavaScript</a>, as if
        it had been written in CoffeeScript instead. Covers language features
        as well as the functional and object oriented programming styles. By
        <a href="https://github.com/autotelicum">E. Hoigaard</a>.
      </li>
      <li>
        <a href="http://pragprog.com/book/tbcoffee/coffeescript">CoffeeScript: Accelerated JavaScript Development</a>
        is <a href="http://trevorburnham.com/">Trevor Burnham</a>'s thorough
        introduction to the language. By the end of the book, you'll have built
        a fast-paced multiplayer word game, writing both the client-side and Node.js
        portions in CoffeeScript.
      </li>
      <li>
        <a href="http://www.packtpub.com/coffeescript-programming-with-jquery-rails-nodejs/book">CoffeeScript Programming with jQuery, Rails, and Node.js</a>
        is a new book by Michael Erasmus that covers CoffeeScript with an eye
        towards real-world usage both in the browser (jQuery) and on the server
        size (Rails, Node).
      </li>
      <li>
        <a href="https://leanpub.com/coffeescript-ristretto/read">CoffeeScript Ristretto</a>
        is a deep dive into CoffeeScript's semantics from simple functions up through
        closures, higher-order functions, objects, classes, combinators, and decorators.
        By <a href="http://braythwayt.com/">Reg Braithwaite</a>.
      </li>
      <li>
        <a href="https://efendibooks.com/minibooks/testing-with-coffeescript">Testing with CoffeeScript</a>
        is a succinct and freely downloadable guide to building testable
        applications with CoffeeScript and Jasmine.
      </li>
      <li>
        <a href="http://www.packtpub.com/coffeescript-application-development/book">CoffeeScript Application Development</a>
        from Packt, introduces CoffeeScript while
        walking through the process of building a demonstration web application.
        A <a href="https://www.packtpub.com/web-development/coffeescript-application-development-cookbook">CoffeeScript Application Development Coookbook</a>
        with over 90 "recipes" is also available.
      </li>
      <li>
        <a href="http://www.manning.com/lee/">CoffeeScript in Action</a>
        from Manning Publications, covers CoffeeScript syntax, composition techniques
        and application development.
      </li>
      <li>
        <a href="http://www.dpunkt.de/buecher/4021/coffeescript.html">CoffeeScript: Die Alternative zu JavaScript</a>
        from dpunkt.verlag, is the first CoffeeScript book in Deutsch.
      </li>
    </ul>

    <h2>
      Screencasts
    </h2>

    <ul>
      <li>
        <a href="http://coffeescript.codeschool.com">A Sip of CoffeeScript</a> is a <a href="http://www.codeschool.com">Code School Course</a>
        which combines 6 screencasts with in-browser coding to make learning fun.  The first level is free to try out.
      </li>
      <li>
        <a href="http://peepcode.com/products/coffeescript">Meet CoffeeScript</a>
        is a 75-minute long screencast by <a href="http://peepcode.com/">PeepCode</a>.
        Highly memorable for its animations which demonstrate transforming CoffeeScript
        into the equivalent JS.
      </li>
      <li>
        If you're looking for less of a time commitment, RailsCasts'
        <a href="http://railscasts.com/episodes/267-coffeescript-basics">CoffeeScript Basics</a>
        should have you covered, hitting all of the important notes about CoffeeScript
        in 11 minutes.
      </li>
    </ul>

    <h2>
      Examples
    </h2>

    <p>
      The <a href="https://github.com/trending?l=coffeescript&amp;since=monthly">best list of
      open-source CoffeeScript examples</a> can be found on GitHub. But just
      to throw out few more:
    </p>

    <ul>
      <li>
        <b>github</b>'s <a href="http://hubot.github.com/">Hubot</a>,
        a friendly IRC robot that can perform any number of useful and useless tasks.
      </li>
      <li>
        <b>sstephenson</b>'s <a href="http://pow.cx/">Pow</a>,
        a zero-configuration Rack server, with comprehensive annotated source.
      </li>
      <li>
        <b>technoweenie</b>'s <a href="https://github.com/technoweenie/coffee-resque">Coffee-Resque</a>,
        a port of <a href="https://github.com/defunkt/resque">Resque</a> for Node.js.
      </li>
      <li>
        <b>assaf</b>'s <a href="http://zombie.labnotes.org/">Zombie.js</a>,
        a headless, full-stack, faux-browser testing library for Node.js.
      </li>
      <li>
        <b>jashkenas</b>' <a href="documentation/docs/underscore.html">Underscore.coffee</a>, a port
        of the <a href="http://documentcloud.github.com/underscore/">Underscore.js</a>
        library of helper functions.
      </li>
      <li>
        <b>stephank</b>'s <a href="https://github.com/stephank/orona">Orona</a>, a remake of
        the Bolo tank game for modern browsers.
      </li>
      <li>
        <b>github</b>'s <a href="https://atom.io/">Atom</a>,
        a hackable text editor built on web technologies.
      </li>
    </ul>

    <h2>
      Resources
    </h2>

    <ul>
      <li>
        <a href="http://github.com/jashkenas/coffeescript/">Source Code</a><br />
        Use <code>bin/coffee</code> to test your changes,<br />
        <code>bin/cake test</code> to run the test suite,<br />
        <code>bin/cake build</code> to rebuild the CoffeeScript compiler, and <br />
        <code>bin/cake build:parser</code> to regenerate the Jison parser if you're
        working on the grammar. <br /><br />
        <code>git checkout lib &amp;&amp; bin/cake build:full</code> is a good command to run when you're working
        on the core language. It'll refresh the lib directory
        (in case you broke something), build your altered compiler, use that to
        rebuild itself (a good sanity test) and then run all of the tests. If
        they pass, there's a good chance you've made a successful change.
      </li>
      <li>
        <a href="http://github.com/jashkenas/coffeescript/issues">CoffeeScript Issues</a><br />
        Bug reports, feature proposals, and ideas for changes to the language belong here.
      </li>
      <li>
        <a href="https://groups.google.com/forum/#!forum/coffeescript">CoffeeScript Google Group</a><br />
        If you'd like to ask a question, the mailing list is a good place to get help.
      </li>
      <li>
        <a href="http://github.com/jashkenas/coffeescript/wiki">The CoffeeScript Wiki</a><br />
        If you've ever learned a neat CoffeeScript tip or trick, or ran into a gotcha &mdash; share it on the wiki.
        The wiki also serves as a directory of handy
        <a href="http://github.com/jashkenas/coffeescript/wiki/Text-editor-plugins">text editor extensions</a>,
        <a href="http://github.com/jashkenas/coffeescript/wiki/Web-framework-plugins">web framework plugins</a>,
        and general <a href="http://github.com/jashkenas/coffeescript/wiki/Build-tools">CoffeeScript build tools</a>.
      </li>
      <li>
        <a href="http://github.com/jashkenas/coffeescript/wiki/FAQ">The FAQ</a><br />
        Perhaps your CoffeeScript-related question has been asked before. Check the FAQ first.
      </li>
      <li>
        <a href="http://js2coffee.org">JS2Coffee</a><br />
        Is a very well done reverse JavaScript-to-CoffeeScript compiler. It's
        not going to be perfect (infer what your JavaScript classes are, when
        you need bound functions, and so on...) &mdash; but it's a great starting
        point for converting simple scripts.
      </li>
      <li>
        <a href="https://github.com/jashkenas/coffeescript/downloads">High-Rez Logo</a><br />
        The CoffeeScript logo is available in Illustrator, EPS and PSD formats, for use
        in presentations.
      </li>
    </ul>

    <h2>
      <span id="webchat" class="bookmark"></span>
      Web Chat (IRC)
    </h2>

    <p>
      Quick help and advice can usually be found in the CoffeeScript IRC room.
      Join <code>#coffeescript</code> on <code>irc.freenode.net</code>, or click the
      button below to open a webchat session on this page.
    </p>

    <p>
      <button id="open_webchat">click to open #coffeescript</button>
    </p>

    <h2>
      <span id="changelog" class="bookmark"></span>
      Change Log
    </h2>

    <p>
      <div class="anchor" id="1.10.0"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/1.9.3...1.10.0">1.10.0</a>
  <span class="timestamp"> &mdash; <time datetime="2015-09-04">September 4, 2015</time></span>
</b>
      <ul>
        <li>
          CoffeeScript now supports ES6-style destructuring defaults.
        </li>
        <li>
          <code>(offsetHeight: height) -&gt;</code> no longer compiles. That
          syntax was accidental and partly broken. Use <code>({offsetHeight:
          height}) -&gt;</code> instead. Object destructuring always requires
          braces.
        </li>
        <li>
          <p>Several minor bug fixes, including:</p>
          <ul>
            <li>
              A bug where the REPL would sometimes report valid code as invalid,
              based on what you had typed earlier.
            </li>
            <li>
              A problem with multiple JS contexts in the jest test framework.
            </li>
            <li>
              An error in io.js where strict mode is set on internal modules.
            </li>
            <li>
              A variable name clash for the caught error in <code>catch</code>
              blocks.
            </li>
          </ul>
        </li>
      </ul>
    </p>

    <p>
      <div class="anchor" id="1.9.3"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/1.9.2...1.9.3">1.9.3</a>
  <span class="timestamp"> &mdash; <time datetime="2015-05-27">May 27, 2015</time></span>
</b>
      <ul>
        <li>
          Bugfix for interpolation in the first key of an object literal in an
          implicit call.
        </li>
        <li>
          Fixed broken error messages in the REPL, as well as a few minor bugs
          with the REPL.
        </li>
        <li>
          Fixed source mappings for tokens at the beginning of lines when
          compiling with the <code>--bare</code> option. This has the nice side
          effect of generating smaller source maps.
        </li>
        <li>
          Slight formatting improvement of compiled block comments.
        </li>
        <li>
          Better error messages for <code>on</code>, <code>off</code>, <code>yes</code> and
          <code>no</code>.
        </li>
      </ul>
    </p>

    <p>
      <div class="anchor" id="1.9.2"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/1.9.1...1.9.2">1.9.2</a>
  <span class="timestamp"> &mdash; <time datetime="2015-04-15">April 15, 2015</time></span>
</b>
      <ul>
        <li>
          Fixed a <b>watch</b> mode error introduced in 1.9.1 when compiling
          multiple files with the same filename.
        </li>
        <li>
          Bugfix for <code>yield</code> around expressions containing
          <code>this</code>.
        </li>
        <li>
          Added a Ruby-style <code>-r</code> option to the REPL, which allows
          requiring a module before execution with <code>--eval</code> or
          <code>--interactive</code>.
        </li>
        <li>
          In <code>&lt;script type="text/coffeescript"&gt;</code> tags, to avoid
          possible duplicate browser requests for .coffee files, 
          you can now use the <code>data-src</code> attribute instead of <code>src</code>.
        </li>
        <li>
          Minor bug fixes for IE8, strict ES5 regular expressions and Browserify.
        </li>
      </ul>
    </p>

    <p>
      <div class="anchor" id="1.9.1"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/1.9.0...1.9.1">1.9.1</a>
  <span class="timestamp"> &mdash; <time datetime="2015-02-18">February 18, 2015</time></span>
</b>
      <ul>
        <li>
          Interpolation now works in object literal keys (again). You can use this to
          dynamically name properties.
        </li>
        <li>
          Internal compiler variable names no longer start with underscores. This makes
          the generated JavaScript a bit prettier, and also fixes an issue with
          the completely broken and ungodly way that AngularJS "parses" function
          arguments.
        </li>
        <li>
          Fixed a few <code>yield</code>-related edge cases with <code>yield return</code>
          and <code>yield throw</code>.
        </li>
        <li>
          Minor bug fixes and various improvements to compiler error messages.
        </li>
      </ul>
    </p>

    <p>
      <div class="anchor" id="1.9.0"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/1.8.0...1.9.0">1.9.0</a>
  <span class="timestamp"> &mdash; <time datetime="2015-01-29">January 29, 2015</time></span>
</b>
      <ul>
        <li>
          CoffeeScript now supports ES6 generators. A generator is simply a function
          that <code>yield</code>s.
        </li>
        <li>
          More robust parsing and improved error messages for strings and regexes —
          especially with respect to interpolation.
        </li>
        <li>
          Changed strategy for the generation of internal compiler variable names.
          Note that this means that <code>@example</code> function parameters are no longer
          available as naked <code>example</code> variables within the function body.
        </li>
        <li>
          Fixed REPL compatibility with latest versions of Node and Io.js.
        </li>
        <li>
          Various minor bug fixes.
        </li>
      </ul>
    </p>

    <p>
      <div class="anchor" id="1.8.0"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/1.7.1...1.8.0">1.8.0</a>
  <span class="timestamp"> &mdash; <time datetime="2014-08-26">August 26, 2014</time></span>
</b>
      <ul>
        <li>
          The <code>--join</code> option of the CLI is now deprecated.
        </li>
        <li>
          Source maps now use <code>.js.map</code> as file extension, instead of just <code>.map</code>.
        </li>
        <li>
          The CLI now exits with the exit code 1 when it fails to write a file to disk.
        </li>
        <li>
          The compiler no longer crashes on unterminated, single-quoted strings.
        </li>
        <li>
          Fixed location data for string interpolations, which made source maps out of sync.
        </li>
        <li>
          The error marker in error messages is now correctly positioned if the code is indented with tabs.
        </li>
        <li>
          Fixed a slight formatting error in CoffeeScript’s source map-patched stack traces.
        </li>
        <li>
          The <code>%%</code> operator now coerces its right operand only once.
        </li>
        <li>
          It is now possible to require CoffeeScript files from Cakefiles without having to register the compiler first.
        </li>
        <li>
          The CoffeeScript REPL is now exported and can be required using <code>require 'coffee-script/repl'</code>.
        </li>
        <li>
          Fixes for the REPL in Node 0.11.
        </li>
      </ul>
    </p>

    <p>
      <div class="anchor" id="1.7.1"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/1.7.0...1.7.1">1.7.1</a>
  <span class="timestamp"> &mdash; <time datetime="2014-01-29">January 29, 2014</time></span>
</b>
      <ul>
        <li>
          Fixed a typo that broke node module lookup when running a script directly with the <code>coffee</code> binary.
        </li>
      </ul>
    </p>
    <p>
      <div class="anchor" id="1.7.0"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/1.6.3...1.7.0">1.7.0</a>
  <span class="timestamp"> &mdash; <time datetime="2014-01-28">January 28, 2014</time></span>
</b>
      <ul>
        <li>
          When requiring CoffeeScript files in Node you must now explicitly register the compiler. This can be done with <code>require 'coffee-script/register'</code> or <code>CoffeeScript.register()</code>. Also for configuration such as Mocha's, use <b>coffee-script/register</b>.
        </li>
        <li>
          Improved error messages, source maps and stack traces. Source maps now use the updated <code>//#</code> syntax.
        </li>
        <li>
          Leading <code>.</code> now closes all open calls, allowing for simpler chaining syntax.
        </li>
      </ul>
      <div class='code'><pre><code>$ <span class="string">'body'</span>
.click <span class="function"><span class="params">(e)</span> -&gt;</span>
  $ <span class="string">'.box'</span>
  .fadeIn <span class="string">'fast'</span>
  .addClass <span class="string">'.active'</span>
.css <span class="string">'background'</span>, <span class="string">'white'</span>
</code></pre><pre><code>$(<span class="string">'body'</span>).click(<span class="function"><span class="keyword">function</span><span class="params">(e)</span> {</span>
  <span class="keyword">return</span> $(<span class="string">'.box'</span>).fadeIn(<span class="string">'fast'</span>).addClass(<span class="string">'.active'</span>);
}).css(<span class="string">'background'</span>, <span class="string">'white'</span>);
</code></pre><script>window.example45 = "$ 'body'\n.click (e) ->\n  $ '.box'\n  .fadeIn 'fast'\n  .addClass '.active'\n.css 'background', 'white'\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example45);'>load</div><br class='clear' /></div>
      <ul>
        <li>
          Added <code>**</code>, <code>//</code> and <code>%%</code> operators and <code>...</code> expansion in parameter lists and destructuring expressions.
        </li>
        <li>
          Multiline strings are now joined by a single space and ignore all indentation. A backslash at the end of a line can denote the amount of whitespace between lines, in both strings and heredocs. Backslashes correctly escape whitespace in block regexes.
        </li>
        <li>
          Closing brackets can now be indented and therefore no longer cause unexpected error.
        </li>
        <li>
          Several breaking compilation fixes. Non-callable literals (strings, numbers etc.) don't compile in a call now and multiple postfix conditionals compile properly. Postfix conditionals and loops always bind object literals. Conditional assignment compiles properly in subexpressions. <code>super</code> is disallowed outside of methods and works correctly inside <code>for</code> loops.
        </li>
        <li>
          Formatting of compiled block comments has been improved.
        </li>
        <li>
          No more <code>-p</code> folders on Windows.
        </li>
        <li>
          The <code>options</code> object passed to CoffeeScript is no longer mutated.
        </li>
      </ul>
    </p>
    <p>
      <div class="anchor" id="1.6.3"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/1.6.2...1.6.3">1.6.3</a>
  <span class="timestamp"> &mdash; <time datetime="2013-06-02">June 2, 2013</time></span>
</b>
      <ul>
        <li>
          The CoffeeScript REPL now remembers your history between sessions.
          Just like a proper REPL should.
        </li>
        <li>
          You can now use <code>require</code> in Node to load <code>.coffee.md</code>
          Literate CoffeeScript files. In the browser,
          <code>text/literate-coffeescript</code> script tags.
        </li>
        <li>
          The old <code>coffee --lint</code> command has been removed. It was useful
          while originally working on the compiler, but has been surpassed by
          JSHint. You may now use <code>-l</code> to pass literate files in over
          <b>stdio</b>.
        </li>
        <li>
          Bugfixes for Windows path separators, <code>catch</code> without naming
          the error, and executable-class-bodies-with-
          prototypal-property-attachment.
        </li>
      </ul>
    </p>

    <p>
      <div class="anchor" id="1.6.2"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/1.6.1...1.6.2">1.6.2</a>
  <span class="timestamp"> &mdash; <time datetime="2013-03-18">March 18, 2013</time></span>
</b>
      <ul>
        <li>
          Source maps have been used to provide automatic line-mapping when
          running CoffeeScript directly via the <code>coffee</code> command, and
          for automatic line-mapping when running CoffeeScript directly in the
          browser. Also, to provide better error messages for semantic errors
          thrown by the compiler &mdash;
          <a href="http://cl.ly/NdOA">with colors, even</a>.
        </li>
        <li>
          Improved support for mixed literate/vanilla-style CoffeeScript projects,
          and generating source maps for both at the same time.
        </li>
        <li>
          Fixes for <b>1.6.x</b> regressions with overriding inherited bound
          functions, and for Windows file path management.
        </li>
        <li>
          The <code>coffee</code> command can now correctly <code>fork()</code>
          both <code>.coffee</code> and <code>.js</code> files. (Requires Node.js 0.9+)
        </li>
      </ul>
    </p>

    <p>
      <div class="anchor" id="1.6.1"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/1.5.0...1.6.1">1.6.1</a>
  <span class="timestamp"> &mdash; <time datetime="2013-03-05">March 5, 2013</time></span>
</b>
      <ul>
        <li>
          First release of <a href="#source-maps">source maps</a>. Pass the
          <code>--map</code> flag to the compiler, and off you go. Direct all your
          thanks over to <a href="http://github.com/jwalton">Jason Walton</a>.
        </li>
        <li>
          Fixed a 1.5.0 regression with multiple implicit calls against an
          indented implicit object. Combinations of implicit function calls
          and implicit objects should generally be parsed better now &mdash;
          but it still isn't good <i>style</i> to nest them too heavily.
        </li>
        <li>
          <code>.coffee.md</code> is now also supported as a Literate CoffeeScript
          file extension, for existing tooling.
          <code>.litcoffee</code> remains the canonical one.
        </li>
        <li>
          Several minor fixes surrounding member properties, bound methods and
          <code>super</code> in class declarations.
        </li>
      </ul>
    </p>

    <p>
      <div class="anchor" id="1.5.0"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/1.4.0...1.5.0">1.5.0</a>
  <span class="timestamp"> &mdash; <time datetime="2013-02-25">February 25, 2013</time></span>
</b>
      <ul>
        <li>
          First release of <a href="#literate">Literate CoffeeScript</a>.
        </li>
        <li>
          The CoffeeScript REPL is now based on the Node.js REPL, and should work
          better and more familiarly.
        </li>
        <li>
          Returning explicit values from constructors is now forbidden. If you want
          to return an arbitrary value, use a function, not a constructor.
        </li>
        <li>
          You can now loop over an array backwards, without having to manually
          deal with the indexes: <code>for item in list by -1</code>
        </li>
        <li>
          Source locations are now preserved in the CoffeeScript AST, although
          source maps are not yet being emitted.
        </li>
      </ul>
    </p>

    <p>
      <div class="anchor" id="1.4.0"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/1.3.3...1.4.0">1.4.0</a>
  <span class="timestamp"> &mdash; <time datetime="2012-10-23">October 23, 2012</time></span>
</b>
      <ul>
        <li>
          The CoffeeScript compiler now strips Microsoft's UTF-8 BOM if it
          exists, allowing you to compile BOM-borked source files.
        </li>
        <li>
          Fix Node/compiler deprecation warnings by removing <code>registerExtension</code>,
          and moving from <code>path.exists</code> to <code>fs.exists</code>.
        </li>
        <li>
          Small tweaks to splat compilation, backticks, slicing, and the
          error for duplicate keys in object literals.
        </li>
      </ul>
    </p>

    <p>
      <div class="anchor" id="1.3.3"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/1.3.1...1.3.3">1.3.3</a>
  <span class="timestamp"> &mdash; <time datetime="2012-05-15">May 15, 2012</time></span>
</b>
      <ul>
        <li>
          Due to the new semantics of JavaScript's strict mode, CoffeeScript no
          longer guarantees that constructor functions have names in all runtimes.
          See <a href="https://github.com/jashkenas/coffeescript/issues/2052">#2052</a>
          for discussion.
        </li>
        <li>
          Inside of a nested function inside of an instance method, it's now possible
          to call <code>super</code> more reliably (walks recursively up).
        </li>
        <li>
          Named loop variables no longer have different scoping heuristics than
          other local variables. (Reverts #643)
        </li>
        <li>
          Fix for splats nested within the LHS of destructuring assignment.
        </li>
        <li>
          Corrections to our compile time strict mode forbidding of octal literals.
        </li>
      </ul>
    </p>

    <p>
      <div class="anchor" id="1.3.1"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/1.2.0...1.3.1">1.3.1</a>
  <span class="timestamp"> &mdash; <time datetime="2012-04-10">April 10, 2012</time></span>
</b>
      <ul>
        <li>
          CoffeeScript now enforces all of JavaScript's <b>Strict Mode</b> early syntax
          errors at compile time. This includes old-style octal literals,
          duplicate property names in object literals, duplicate parameters in
          a function definition, deleting naked variables, setting the value of
          <code>eval</code> or <code>arguments</code>, and more.
          See a full discussion at
          <a href="https://github.com/jashkenas/coffeescript/issues/1547">#1547</a>.
        </li>
        <li>
          The REPL now has a handy new multi-line mode for entering large
          blocks of code. It's useful when copy-and-pasting examples into the
          REPL. Enter multi-line mode with <code>Ctrl-V</code>. You may also now
          pipe input directly into the REPL.
        </li>
        <li>
          CoffeeScript now prints a <code>Generated by CoffeeScript VERSION</code>
          header at the top of each compiled file.
        </li>
        <li>
          Conditional assignment of previously undefined variables
          <code>a or= b</code> is now considered a syntax error.
        </li>
        <li>
          A tweak to the semantics of <code>do</code>, which can now be used to
          more easily simulate a namespace: <code>do (x = 1, y = 2) -> ...</code>
        </li>
        <li>
          Loop indices are now mutable within a loop iteration, and immutable
          between them.
        </li>
        <li>
          Both endpoints of a slice are now allowed to be omitted for consistency,
          effectively creating a shallow copy of the list.
        </li>
        <li>
          Additional tweaks and improvements to <code>coffee --watch</code> under
          Node's "new" file watching API. Watch will now beep by default
          if you introduce a syntax error into a watched script. We also now
          ignore hidden directories by default when watching recursively.
        </li>
      </ul>
    </p>

    <p>
      <div class="anchor" id="1.2.0"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/1.1.3...1.2.0">1.2.0</a>
  <span class="timestamp"> &mdash; <time datetime="2011-12-18">December 18, 2011</time></span>
</b>
      <ul>
        <li>
          Multiple improvements to <code>coffee --watch</code> and <code>--join</code>.
          You may now use both together, as well as add and remove
          files and directories within a <code>--watch</code>'d folder.
        </li>
        <li>
          The <code>throw</code> statement can now be used as part of an expression.
        </li>
        <li>
          Block comments at the top of the file will now appear outside of the
          safety closure wrapper.
        </li>
        <li>
          Fixed a number of minor 1.1.3 regressions having to do with trailing
          operators and unfinished lines, and a more major 1.1.3 regression that
          caused bound functions <i>within</i> bound class functions to have the incorrect
          <code>this</code>.
        </li>
      </ul>
    </p>

    <p>
      <div class="anchor" id="1.1.3"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/1.1.2...1.1.3">1.1.3</a>
  <span class="timestamp"> &mdash; <time datetime="2011-11-08">November 8, 2011</time></span>
</b>
      <ul>
        <li>
          Ahh, whitespace. CoffeeScript's compiled JS now tries to space things
          out and keep it readable, as you can see in the examples on this page.
        </li>
        <li>
          You can now call <code>super</code> in class level methods in class bodies,
          and bound class methods now preserve their correct context.
        </li>
        <li>
          JavaScript has always supported octal numbers <code>010 is 8</code>,
          and hexadecimal numbers <code>0xf is 15</code>, but CoffeeScript now
          also supports binary numbers: <code>0b10 is 2</code>.
        </li>
        <li>
          The CoffeeScript module has been nested under a subdirectory to make
          it easier to <code>require</code> individual components separately, without
          having to use <b>npm</b>. For example, after adding the CoffeeScript
          folder to your path: <code>require('coffee-script/lexer')</code>
        </li>
        <li>
          There's a new "link" feature in Try CoffeeScript on this webpage. Use
          it to get a shareable permalink for your example script.
        </li>
        <li>
          The <code>coffee --watch</code> feature now only works on Node.js 0.6.0
          and higher, but now also works properly on Windows.
        </li>
        <li>
          Lots of small bug fixes from
          <b><a href="https://github.com/michaelficarra">@michaelficarra</a></b>,
          <b><a href="https://github.com/geraldalewis">@geraldalewis</a></b>,
          <b><a href="https://github.com/satyr">@satyr</a></b>, and
          <b><a href="https://github.com/trevorburnham">@trevorburnham</a></b>.
        </li>
      </ul>
    </p>

    <p>
      <div class="anchor" id="1.1.2"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/1.1.1...1.1.2">1.1.2</a>
  <span class="timestamp"> &mdash; <time datetime="2011-08-04">August 4, 2011</time></span>
</b>
      Fixes for block comment formatting, <code>?=</code> compilation, implicit calls
      against control structures, implicit invocation of a try/catch block,
      variadic arguments leaking from local scope, line numbers in syntax errors
      following heregexes, property access on parenthesized number literals,
      bound class methods and super with reserved names, a REPL overhaul,
      consecutive compiled semicolons, block comments in implicitly called objects,
      and a Chrome bug.
    </p>

    <p>
      <div class="anchor" id="1.1.1"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/1.1.0...1.1.1">1.1.1</a>
  <span class="timestamp"> &mdash; <time datetime="2011-05-10">May 10, 2011</time></span>
</b>
      Bugfix release for classes with external constructor functions, see
      issue #1182.
    </p>

    <p>
      <div class="anchor" id="1.1.0"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/1.0.1...1.1.0">1.1.0</a>
  <span class="timestamp"> &mdash; <time datetime="2011-05-01">May 1, 2011</time></span>
</b>
      When running via the <code>coffee</code> executable, <code>process.argv</code> and
      friends now report <code>coffee</code> instead of <code>node</code>.
      Better compatibility with <b>Node.js 0.4.x</b> module lookup changes.
      The output in the REPL is now colorized, like Node's is.
      Giving your concatenated CoffeeScripts a name when using <code>--join</code> is now mandatory.
      Fix for lexing compound division <code>/=</code> as a regex accidentally.
      All <code>text/coffeescript</code> tags should now execute in the order they're included.
      Fixed an issue with extended subclasses using external constructor functions.
      Fixed an edge-case infinite loop in <code>addImplicitParentheses</code>.
      Fixed exponential slowdown with long chains of function calls.
      Globals no longer leak into the CoffeeScript REPL.
      Splatted parameters are declared local to the function.
    </p>

    <p>
      <div class="anchor" id="1.0.1"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/1.0.0...1.0.1">1.0.1</a>
  <span class="timestamp"> &mdash; <time datetime="2011-01-31">January 31, 2011</time></span>
</b>
      Fixed a lexer bug with Unicode identifiers. Updated REPL for compatibility
      with Node.js 0.3.7. Fixed requiring relative paths in the REPL. Trailing
      <code>return</code> and <code>return undefined</code> are now optimized away.
      Stopped requiring the core Node.js <code>"util"</code> module for
      back-compatibility with Node.js 0.2.5. Fixed a case where a
      conditional <code>return</code> would cause fallthrough in a <code>switch</code>
      statement. Optimized empty objects in destructuring assignment.
    </p>

    <p>
      <div class="anchor" id="1.0.0"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/0.9.6...1.0.0">1.0.0</a>
  <span class="timestamp"> &mdash; <time datetime="2010-12-24">December 24, 2010</time></span>
</b>
      CoffeeScript loops no longer try to preserve block scope when functions
      are being generated within the loop body. Instead, you can use the
      <code>do</code> keyword to create a convenient closure wrapper.
      Added a <code>--nodejs</code> flag for passing through options directly
      to the <code>node</code> executable.
      Better behavior around the use of pure statements within expressions.
      Fixed inclusive slicing through <code>-1</code>, for all browsers, and splicing
      with arbitrary expressions as endpoints.
    </p>

    <p>
      <div class="anchor" id="0.9.6"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/0.9.5...0.9.6">0.9.6</a>
  <span class="timestamp"> &mdash; <time datetime="2010-12-06">December 6, 2010</time></span>
</b>
      The REPL now properly formats stacktraces, and stays alive through
      asynchronous exceptions. Using <code>--watch</code> now prints timestamps as
      files are compiled. Fixed some accidentally-leaking variables within
      plucked closure-loops. Constructors now maintain their declaration
      location within a class body. Dynamic object keys were removed.
      Nested classes are now supported. Fixes execution context for naked
      splatted functions. Bugfix for inversion of chained comparisons.
      Chained class instantiation now works properly with splats.
    </p>

    <p>
      <div class="anchor" id="0.9.5"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/0.9.4...0.9.5">0.9.5</a>
  <span class="timestamp"> &mdash; <time datetime="2010-11-21">November 21, 2010</time></span>
</b>
      0.9.5 should be considered the first release candidate for CoffeeScript 1.0.
      There have been a large number of internal changes since the previous release,
      many contributed from <b>satyr</b>'s <a href="http://github.com/satyr/coco">Coco</a>
      dialect of CoffeeScript. Heregexes (extended regexes) were added. Functions
      can now have default arguments. Class bodies are now executable code.
      Improved syntax errors for invalid CoffeeScript. <code>undefined</code> now
      works like <code>null</code>, and cannot be assigned a new value.
      There was a precedence change with respect to single-line comprehensions:
      <code>result = i for i in list</code><br /> used to parse as <code>result = (i for i in list)</code>
      by default ... it now parses as <br /><code>(result = i) for i in list</code>.
    </p>

    <p>
      <div class="anchor" id="0.9.4"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/0.9.3...0.9.4">0.9.4</a>
  <span class="timestamp"> &mdash; <time datetime="2010-09-21">September 21, 2010</time></span>
</b>
      CoffeeScript now uses appropriately-named temporary variables, and recycles
      their references after use. Added <code>require.extensions</code> support for
      <b>Node.js 0.3</b>. Loading CoffeeScript in the browser now adds just a
      single <code>CoffeeScript</code> object to global scope.
      Fixes for implicit object and block comment edge cases.
    </p>

    <p>
      <div class="anchor" id="0.9.3"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/0.9.2...0.9.3">0.9.3</a>
  <span class="timestamp"> &mdash; <time datetime="2010-09-16">September 16, 2010</time></span>
</b>
      CoffeeScript <code>switch</code> statements now compile into JS <code>switch</code>
      statements &mdash; they previously compiled into <code>if/else</code> chains
      for JavaScript 1.3 compatibility.
      Soaking a function invocation is now supported. Users of the RubyMine
      editor should now be able to use <code>--watch</code> mode.
    </p>

    <p>
      <div class="anchor" id="0.9.2"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/0.9.1...0.9.2">0.9.2</a>
  <span class="timestamp"> &mdash; <time datetime="2010-08-23">August 23, 2010</time></span>
</b>
      Specifying the start and end of a range literal is now optional, eg. <code>array[3..]</code>.
      You can now say <code>a not instanceof b</code>.
      Fixed important bugs with nested significant and non-significant indentation (Issue #637).
      Added a <code>--require</code> flag that allows you to hook into the <code>coffee</code> command.
      Added a custom <code>jsl.conf</code> file for our preferred JavaScriptLint setup.
      Sped up Jison grammar compilation time by flattening rules for operations.
      Block comments can now be used with JavaScript-minifier-friendly syntax.
      Added JavaScript's compound assignment bitwise operators. Bugfixes to
      implicit object literals with leading number and string keys, as the subject
      of implicit calls, and as part of compound assignment.
    </p>

    <p>
      <div class="anchor" id="0.9.1"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/0.9.0...0.9.1">0.9.1</a>
  <span class="timestamp"> &mdash; <time datetime="2010-08-11">August 11, 2010</time></span>
</b>
      Bugfix release for <b>0.9.1</b>. Greatly improves the handling of mixed
      implicit objects, implicit function calls, and implicit indentation.
      String and regex interpolation is now strictly <code>#{ ... }</code> (Ruby style).
      The compiler now takes a <code>--require</code> flag, which specifies scripts
      to run before compilation.
    </p>

    <p>
      <div class="anchor" id="0.9.0"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/0.7.2...0.9.0">0.9.0</a>
  <span class="timestamp"> &mdash; <time datetime="2010-08-04">August 4, 2010</time></span>
</b>
      The CoffeeScript <b>0.9</b> series is considered to be a release candidate
      for <b>1.0</b>; let's give her a shakedown cruise. <b>0.9.0</b> introduces a massive
      backwards-incompatible change: Assignment now uses <code>=</code>, and object
      literals use <code>:</code>, as in JavaScript. This allows us to have implicit
      object literals, and YAML-style object definitions. Half assignments are
      removed, in favor of <code>+=</code>, <code>or=</code>, and friends.
      Interpolation now uses a hash mark <code>#</code> instead of the dollar sign
      <code>$</code> &mdash; because dollar signs may be part of a valid JS identifier.
      Downwards range comprehensions are now safe again, and are optimized to
      straight for loops when created with integer endpoints.
      A fast, unguarded form of object comprehension was added:
      <code>for all key, value of object</code>. Mentioning the <code>super</code> keyword
      with no arguments now forwards all arguments passed to the function,
      as in Ruby. If you extend class <code>B</code> from parent class <code>A</code>, if
      <code>A</code> has an <code>extended</code> method defined, it will be called, passing in <code>B</code> &mdash;
      this enables static inheritance, among other things. Cleaner output for
      functions bound with the fat arrow. <code>@variables</code> can now be used
      in parameter lists, with the parameter being automatically set as a property
      on the object &mdash; useful in constructors and setter functions.
      Constructor functions can now take splats.
    </p>

    <p>
      <div class="anchor" id="0.7.2"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/0.7.1...0.7.2">0.7.2</a>
  <span class="timestamp"> &mdash; <time datetime="2010-07-12">July 12, 2010</time></span>
</b>
      Quick bugfix (right after 0.7.1) for a problem that prevented <code>coffee</code>
      command-line options from being parsed in some circumstances.
    </p>

    <p>
      <div class="anchor" id="0.7.1"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/0.7.0...0.7.1">0.7.1</a>
  <span class="timestamp"> &mdash; <time datetime="2010-07-11">July 11, 2010</time></span>
</b>
      Block-style comments are now passed through and printed as JavaScript block
      comments -- making them useful for licenses and copyright headers. Better
      support for running coffee scripts standalone via hashbangs.
      Improved syntax errors for tokens that are not in the grammar.
    </p>

    <p>
      <div class="anchor" id="0.7.0"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/0.6.2...0.7.0">0.7.0</a>
  <span class="timestamp"> &mdash; <time datetime="2010-06-28">June 28, 2010</time></span>
</b>
      Official CoffeeScript variable style is now camelCase, as in JavaScript.
      Reserved words are now allowed as object keys, and will be quoted for you.
      Range comprehensions now generate cleaner code, but you have to specify <code>by -1</code>
      if you'd like to iterate downward. Reporting of syntax errors is greatly
      improved from the previous release. Running <code>coffee</code> with no arguments
      now launches the REPL, with Readline support. The <code>&lt;-</code> bind operator
      has been removed from CoffeeScript. The <code>loop</code> keyword was added,
      which is equivalent to a <code>while true</code> loop. Comprehensions that contain
      closures will now close over their variables, like the semantics of a <code>forEach</code>.
      You can now use bound function in class definitions (bound to the instance).
      For consistency, <code>a in b</code> is now an array presence check, and <code>a of b</code>
      is an object-key check. Comments are no longer passed through to the generated
      JavaScript.
    </p>

    <p>
      <div class="anchor" id="0.6.2"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/0.6.1...0.6.2">0.6.2</a>
  <span class="timestamp"> &mdash; <time datetime="2010-05-15">May 15, 2010</time></span>
</b>
      The <code>coffee</code> command will now preserve directory structure when
      compiling a directory full of scripts. Fixed two omissions that were preventing
      the CoffeeScript compiler from running live within Internet Explorer.
      There's now a syntax for block comments, similar in spirit to CoffeeScript's heredocs.
      ECMA Harmony DRY-style pattern matching is now supported, where the name
      of the property is the same as the name of the value: <code>{name, length}: func</code>.
      Pattern matching is now allowed within comprehension variables. <code>unless</code>
      is now allowed in block form. <code>until</code> loops were added, as the inverse
      of <code>while</code> loops. <code>switch</code> statements are now allowed without
      switch object clauses. Compatible
      with Node.js <b>v0.1.95</b>.
    </p>

    <p>
      <div class="anchor" id="0.6.1"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/0.6.0...0.6.1">0.6.1</a>
  <span class="timestamp"> &mdash; <time datetime="2010-04-12">April 12, 2010</time></span>
</b>
      Upgraded CoffeeScript for compatibility with the new Node.js <b>v0.1.90</b>
      series.
    </p>

    <p>
      <div class="anchor" id="0.6.0"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/0.5.6...0.6.0">0.6.0</a>
  <span class="timestamp"> &mdash; <time datetime="2010-04-03">April 3, 2010</time></span>
</b>
      Trailing commas are now allowed, a-la Python. Static
      properties may be assigned directly within class definitions,
      using <code>@property</code> notation.
    </p>

    <p>
      <div class="anchor" id="0.5.6"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/0.5.5...0.5.6">0.5.6</a>
  <span class="timestamp"> &mdash; <time datetime="2010-03-23">March 23, 2010</time></span>
</b>
      Interpolation can now be used within regular expressions and heredocs, as well as
      strings. Added the <code>&lt;-</code> bind operator.
      Allowing assignment to half-expressions instead of special <code>||=</code>-style
      operators. The arguments object is no longer automatically converted into
      an array. After requiring <code>coffee-script</code>, Node.js can now directly
      load <code>.coffee</code> files, thanks to <b>registerExtension</b>. Multiple
      splats can now be used in function calls, arrays, and pattern matching.
    </p>

    <p>
      <div class="anchor" id="0.5.5"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/0.5.4...0.5.5">0.5.5</a>
  <span class="timestamp"> &mdash; <time datetime="2010-03-08">March 8, 2010</time></span>
</b>
      String interpolation, contributed by
      <a href="http://github.com/StanAngeloff">Stan Angeloff</a>.
      Since <code>--run</code> has been the default since <b>0.5.3</b>, updating
      <code>--stdio</code> and <code>--eval</code> to run by default, pass <code>--compile</code>
      as well if you'd like to print the result.
    </p>

    <p>
      <div class="anchor" id="0.5.4"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/0.5.3...0.5.4">0.5.4</a>
  <span class="timestamp"> &mdash; <time datetime="2010-03-03">March 3, 2010</time></span>
</b>
      Bugfix that corrects the Node.js global constants <code>__filename</code> and
      <code>__dirname</code>. Tweaks for more flexible parsing of nested function
      literals and improperly-indented comments. Updates for the latest Node.js API.
    </p>

    <p>
      <div class="anchor" id="0.5.3"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/0.5.2...0.5.3">0.5.3</a>
  <span class="timestamp"> &mdash; <time datetime="2010-02-27">February 27, 2010</time></span>
</b>
      CoffeeScript now has a syntax for defining classes. Many of the core
      components (Nodes, Lexer, Rewriter, Scope, Optparse) are using them.
      Cakefiles can use <code>optparse.coffee</code> to define options for tasks.
      <code>--run</code> is now the default flag for the <code>coffee</code> command,
      use <code>--compile</code> to save JavaScripts. Bugfix for an ambiguity between
      RegExp literals and chained divisions.
    </p>

    <p>
      <div class="anchor" id="0.5.2"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/0.5.1...0.5.2">0.5.2</a>
  <span class="timestamp"> &mdash; <time datetime="2010-02-25">February 25, 2010</time></span>
</b>
      Added a compressed version of the compiler for inclusion in web pages as
      <br  /><code>extras/coffee-script.js</code>. It'll automatically run any script tags
      with type <code>text/coffeescript</code> for you. Added a <code>--stdio</code> option
      to the <code>coffee</code> command, for piped-in compiles.
    </p>


    <p>
      <div class="anchor" id="0.5.1"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/0.5.0...0.5.1">0.5.1</a>
  <span class="timestamp"> &mdash; <time datetime="2010-02-24">February 24, 2010</time></span>
</b>
      Improvements to null soaking with the existential operator, including
      soaks on indexed properties. Added conditions to <code>while</code> loops,
      so you can use them as filters with <code>when</code>, in the same manner as
      comprehensions.
    </p>

    <p>
      <div class="anchor" id="0.5.0"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/0.3.2...0.5.0">0.5.0</a>
  <span class="timestamp"> &mdash; <time datetime="2010-02-21">February 21, 2010</time></span>
</b>
      CoffeeScript 0.5.0 is a major release, While there are no language changes,
      the Ruby compiler has been removed in favor of a self-hosting
      compiler written in pure CoffeeScript.
    </p>

    <p>
      <div class="anchor" id="0.3.2"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/0.3.0...0.3.2">0.3.2</a>
  <span class="timestamp"> &mdash; <time datetime="2010-02-08">February 8, 2010</time></span>
</b>
      <code>@property</code> is now a shorthand for <code>this.property</code>.<br />
      Switched the default JavaScript engine from Narwhal to Node.js. Pass
      the <code>--narwhal</code> flag if you'd like to continue using it.
    </p>

    <p>
      <div class="anchor" id="0.3.0"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/0.2.6...0.3.0">0.3.0</a>
  <span class="timestamp"> &mdash; <time datetime="2010-01-26">January 26, 2010</time></span>
</b>
      CoffeeScript 0.3 includes major syntax changes:
      <br />
      The function symbol was changed to
      <code>-></code>, and the bound function symbol is now <code>=></code>.
      <br />
      Parameter lists in function definitions must now be wrapped in parentheses.
      <br />
      Added property soaking, with the <code>?.</code> operator.
      <br />
      Made parentheses optional, when invoking functions with arguments.
      <br />
      Removed the obsolete block literal syntax.
    </p>

    <p>
      <div class="anchor" id="0.2.6"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/0.2.5...0.2.6">0.2.6</a>
  <span class="timestamp"> &mdash; <time datetime="2010-01-17">January 17, 2010</time></span>
</b>
      Added Python-style chained comparisons, the conditional existence
      operator <code>?=</code>, and some examples from <i>Beautiful Code</i>.
      Bugfixes relating to statement-to-expression conversion, arguments-to-array
      conversion, and the TextMate syntax highlighter.
    </p>

    <p>
      <div class="anchor" id="0.2.5"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/0.2.4...0.2.5">0.2.5</a>
  <span class="timestamp"> &mdash; <time datetime="2010-01-13">January 13, 2010</time></span>
</b>
      The conditions in switch statements can now take multiple values at once &mdash;
      If any of them are true, the case will run. Added the long arrow <code>==></code>,
      which defines and immediately binds a function to <code>this</code>. While loops can
      now be used as expressions, in the same way that comprehensions can. Splats
      can be used within pattern matches to soak up the rest of an array.
    </p>

    <p>
      <div class="anchor" id="0.2.4"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/0.2.3...0.2.4">0.2.4</a>
  <span class="timestamp"> &mdash; <time datetime="2010-01-12">January 12, 2010</time></span>
</b>
      Added ECMAScript Harmony style destructuring assignment, for dealing with
      extracting values from nested arrays and objects. Added indentation-sensitive
      heredocs for nicely formatted strings or chunks of code.
    </p>

    <p>
      <div class="anchor" id="0.2.3"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/0.2.2...0.2.3">0.2.3</a>
  <span class="timestamp"> &mdash; <time datetime="2010-01-11">January 11, 2010</time></span>
</b>
      Axed the unsatisfactory <code>ino</code> keyword, replacing it with <code>of</code> for
      object comprehensions. They now look like: <code>for prop, value of object</code>.
    </p>

    <p>
      <div class="anchor" id="0.2.2"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/0.2.1...0.2.2">0.2.2</a>
  <span class="timestamp"> &mdash; <time datetime="2010-01-10">January 10, 2010</time></span>
</b>
      When performing a comprehension over an object, use <code>ino</code>, instead
      of <code>in</code>, which helps us generate smaller, more efficient code at
      compile time.
      <br />
      Added <code>::</code> as a shorthand for saying <code>.prototype.</code>
      <br />
      The "splat" symbol has been changed from a prefix asterisk <code>*</code>, to
      a postfix ellipsis <code>...</code>
      <br />
      Added JavaScript's <code>in</code> operator,
      empty <code>return</code> statements, and empty <code>while</code> loops.
      <br />
      Constructor functions that start with capital letters now include a
      safety check to make sure that the new instance of the object is returned.
      <br />
      The <code>extends</code> keyword now functions identically to <code>goog.inherits</code>
      in Google's Closure Library.
    </p>

    <p>
      <div class="anchor" id="0.2.1"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/0.2.0...0.2.1">0.2.1</a>
  <span class="timestamp"> &mdash; <time datetime="2010-01-05">January 5, 2010</time></span>
</b>
      Arguments objects are now converted into real arrays when referenced.
    </p>

    <p>
      <div class="anchor" id="0.2.0"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/0.1.6...0.2.0">0.2.0</a>
  <span class="timestamp"> &mdash; <time datetime="2010-01-05">January 5, 2010</time></span>
</b>
      Major release. Significant whitespace. Better statement-to-expression
      conversion. Splats. Splice literals. Object comprehensions. Blocks.
      The existential operator. Many thanks to all the folks who posted issues,
      with special thanks to
      <a href="http://github.com/liamoc">Liam O'Connor-Davis</a> for whitespace
      and expression help.
    </p>

    <p>
      <div class="anchor" id="0.1.6"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/0.1.5...0.1.6">0.1.6</a>
  <span class="timestamp"> &mdash; <time datetime="2009-12-27">December 27, 2009</time></span>
</b>
      Bugfix for running <code>coffee --interactive</code> and <code>--run</code>
      from outside of the CoffeeScript directory. Bugfix for nested
      function/if-statements.
    </p>

    <p>
      <div class="anchor" id="0.1.5"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/0.1.4...0.1.5">0.1.5</a>
  <span class="timestamp"> &mdash; <time datetime="2009-12-26">December 26, 2009</time></span>
</b>
      Array slice literals and array comprehensions can now both take Ruby-style
      ranges to specify the start and end. JavaScript variable declaration is
      now pushed up to the top of the scope, making all assignment statements into
      expressions. You can use <code>\</code> to escape newlines.
      The <code>coffee-script</code> command is now called <code>coffee</code>.
    </p>

    <p>
      <div class="anchor" id="0.1.4"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/0.1.3...0.1.4">0.1.4</a>
  <span class="timestamp"> &mdash; <time datetime="2009-12-25">December 25, 2009</time></span>
</b>
      The official CoffeeScript extension is now <code>.coffee</code> instead of
      <code>.cs</code>, which properly belongs to
      <a href="http://en.wikipedia.org/wiki/C_Sharp_(programming_language)">C#</a>.
      Due to popular demand, you can now also use <code>=</code> to assign. Unlike
      JavaScript, <code>=</code> can also be used within object literals, interchangeably
      with <code>:</code>. Made a grammatical fix for chained function calls
      like <code>func(1)(2)(3)(4)</code>. Inheritance and super no longer use
      <code>__proto__</code>, so they should be IE-compatible now.
    </p>

    <p>
      <div class="anchor" id="0.1.3"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/0.1.2...0.1.3">0.1.3</a>
  <span class="timestamp"> &mdash; <time datetime="2009-12-25">December 25, 2009</time></span>
</b>
      The <code>coffee</code> command now includes <code>--interactive</code>,
      which launches an interactive CoffeeScript session, and <code>--run</code>,
      which directly compiles and executes a script. Both options depend on a
      working installation of Narwhal.
      The <code>aint</code> keyword has been replaced by <code>isnt</code>, which goes
      together a little smoother with <code>is</code>.
      Quoted strings are now allowed as identifiers within object literals: eg.
      <code>{"5+5": 10}</code>.
      All assignment operators now use a colon: <code>+:</code>, <code>-:</code>,
      <code>*:</code>, etc.
    </p>

    <p>
      <div class="anchor" id="0.1.2"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/0.1.1...0.1.2">0.1.2</a>
  <span class="timestamp"> &mdash; <time datetime="2009-12-24">December 24, 2009</time></span>
</b>
      Fixed a bug with calling <code>super()</code> through more than one level of
      inheritance, with the re-addition of the <code>extends</code> keyword.
      Added experimental <a href="http://narwhaljs.org/">Narwhal</a>
      support (as a Tusk package), contributed by
      <a href="http://tlrobinson.net/">Tom Robinson</a>, including
      <b>bin/cs</b> as a CoffeeScript REPL and interpreter.
      New <code>--no-wrap</code> option to suppress the safety function
      wrapper.
    </p>

    <p>
      <div class="anchor" id="0.1.1"></div>
<b class="header">
  <a href="https://github.com/jashkenas/coffeescript/compare/0.1.0...0.1.1">0.1.1</a>
  <span class="timestamp"> &mdash; <time datetime="2009-12-24">December 24, 2009</time></span>
</b>
      Added <code>instanceof</code> and <code>typeof</code> as operators.
    </p>

    <p>
      <div class="anchor" id="0.1.0"></div>
<b class="header">
  0.1.0
  <span class="timestamp"> &mdash; <time datetime="2009-12-24">December 24, 2009</time></span>
</b>
      Initial CoffeeScript release.
    </p>

  </div>

  <script type="text/coffeescript">
    sourceFragment = "try:"

    # Set up the compilation function, to run when you stop typing.
    compileSource = ->
      source = $('#repl_source').val()
      results = $('#repl_results')
      window.compiledJS = ''
      try
        window.compiledJS = CoffeeScript.compile source, bare: on
        el = results[0]
        if el.innerText
          el.innerText = window.compiledJS
        else
          results.text(window.compiledJS)
        results.removeClass 'error'
        $('.minibutton.run').removeClass 'error'
      catch {location, message}
        if location?
          message = "Error on line #{location.first_line + 1}: #{message}"
        results.text(message).addClass 'error'
        $('.minibutton.run').addClass 'error'

      # Update permalink
      $('#repl_permalink').attr 'href', "##{sourceFragment}#{encodeURIComponent source}"

    # Listen for keypresses and recompile.
    $('#repl_source').keyup -> compileSource()

    # Eval the compiled js.
    evalJS = ->
      try
        eval window.compiledJS
      catch error then alert error

    # Load the console with a string of CoffeeScript.
    window.loadConsole = (coffee) ->
      $('#repl_source').val coffee
      compileSource()
      $('.navigation.try').addClass('active')
      false

    # Helper to hide the menus.
    closeMenus = ->
      $('.navigation.active').removeClass 'active'

    $('.minibutton.run').click -> evalJS()

    # Bind navigation buttons to open the menus.
    $('.navigation').click (e) ->
      return if e.target.tagName.toLowerCase() is 'a'
      return false if $(e.target).closest('.repl_wrapper').length
      if $(this).hasClass('active')
        closeMenus()
      else
        closeMenus()
        $(this).addClass 'active'
      false

    # Dismiss console if Escape pressed or click falls outside console
    # Trigger Run button on Ctrl-Enter
    $(document.body)
      .keydown (e) ->
        closeMenus() if e.which == 27
        evalJS() if e.which == 13 and (e.metaKey or e.ctrlKey) and $('.minibutton.run:visible').length
      .click (e) ->
        return false if $(e.target).hasClass('minibutton')
        closeMenus()

    $('#open_webchat').click ->
      $(this).replaceWith $('<iframe src="http://webchat.freenode.net/?channels=coffeescript" width="625" height="400"></iframe>')

    $("#repl_permalink").click (e) ->
        window.location = $(this).attr("href")
        false

    # If source code is included in location.hash, display it.
    hash = decodeURIComponent location.hash.replace(/^#/, '')
    if hash.indexOf(sourceFragment) == 0
        src = hash.substr sourceFragment.length
        loadConsole src

    compileSource()

  </script>

  <script src="documentation/vendor/jquery-1.6.4.js"></script>
  <script src="extras/coffee-script.js"></script>

</body>
</html>