@@ -30,8 +30,8 @@ console.log('\\u1232Feh'
30
30
a='
31
31
b="\
32
32
still a string
33
-
34
-
33
+
34
+
35
35
function foo(items, nada) {
36
36
for (var i=0; i<items.length; i++) {
37
37
alert(items[i] + "juhu\n");
@@ -66,7 +66,7 @@ string'
66
66
'
67
67
string'
68
68
69
- "trailing space\
69
+ "trailing space\
70
70
" " /not a regexp/g
71
71
72
72
/**
@@ -84,7 +84,7 @@ z>>=t<<f>>r>>>s>=0b1
84
84
foo.protoype.d = function(a, b,
85
85
c, d)
86
86
foo.d =function(a, b)
87
- foo.d =function(a, /*****/ d"string"
87
+ foo.d =function(a, /*****/ d"string"
88
88
89
89
<div
90
90
z=<div {...this.props} x={1 + 2} y="z{a}b&" t={
@@ -98,3 +98,66 @@ var o = {
98
98
return x
99
99
})}`
100
100
};
101
+
102
+ //test generator function
103
+ function* range (start, end, step) {
104
+ while (start < end) {
105
+ yield start
106
+ start += step
107
+ }
108
+ }
109
+ //test ES6 new built-in methods
110
+ "hello".startsWith("ello", 1) // true
111
+ "hello".endsWith("hell", 4) // true
112
+ "hello".includes("ell") // true
113
+ [ 1, 3, 4, 2 ].find(x => x > 3) // 4
114
+ [ 1, 3, 4, 2 ].findIndex(x => x > 3) // 2
115
+ "foo".repeat(3)
116
+ Number.isSafeInteger(42) === true
117
+
118
+ let x = Number.MAX_SAFE_INTEGER;
119
+ let x = Number.MIN_SAFE_INTEGER;
120
+ let x = Number.EPSILON;
121
+ //test Promises
122
+ new Promise(tetheredGetNumber)
123
+ .then(determineParity, troubleWithGetNumber)
124
+ .then(promiseGetWord)
125
+ .then((info) => {
126
+ console.log(`Got: ${info.value}, ${info.wordEvenOdd}`);
127
+ return info;
128
+ })
129
+ .catch((reason) => {
130
+ if (reason.cause) {
131
+ console.error("Had previously handled error");
132
+ } else {
133
+ console.error(`Trouble with promiseGetWord(): ${reason}`);
134
+ }
135
+ })
136
+ .finally((info) => console.log("All done"));
137
+ //test ES6 arrow functions
138
+ param => expression;
139
+
140
+ (param) => expression;
141
+
142
+ (param1 = 123, paramN = "test") => expression;
143
+
144
+ param => {
145
+ statements;
146
+ };
147
+ (param1, paramN) => {
148
+ statements
149
+ }
150
+
151
+ (a, b, ...r) => expression;
152
+
153
+ (a = 400, b = 20, c) => expression;
154
+
155
+ async param => expression;
156
+
157
+ //test JSX functions arguments in arrow functions
158
+ <Component onclick={(param1, param2 = "Test", ...paramN) => {
159
+ console.log("Test")
160
+ }}/>
161
+ <Component onclick={param1 => {
162
+ console.log("Test")
163
+ }}/>
0 commit comments