-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy paththeTest.js
187 lines (155 loc) · 2.54 KB
/
theTest.js
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
// not strict, 'cause we need to parse the with statement
/* jshint strict: false */
// statements after a return are ok for test cases
/* jshint -W027 */
// missing break statements in switch statements are ok
/* jshint -W086 */
var op = {
'+': function (a, b) {return a + b; }
}['+'];
console.log(op(2, 2));
function Test(name) {
this._name = name;
}
Test.prototype.hello = function () {
console.log("Hello,", this._name + "!");
};
var a = new Test("Marten");
a.hello();
for (var i = 0; i < 4; i += 1) {
console.log(i);
}
if (1) {
console.log(2);
}
if (0) {
console.warn(1);
} else {
console.error(3);
}
console.log("Hello World!");
(function (name) {
console.log("Hello", name + "!");
}('Marten'));
var i = 0;
while (i < 2) {
++i;
console.log(i);
}
// works if you use 'global' instead of the custom global object that
// only includes 'console'
//
// process.nextTick(function () {
// console.log("Later...");
// });
function test(def) {
return function () {
return def.abc;
};
}
console.log(test({abc: []})());
var a = (1, 2);
console.log(a);
var i = 0;
do {
console.log(i);
i++;
} while (i < 2);
console.log(1 ? 0 : 1);
console.log(0 ? 0 : 1);
try {
throw new Error('Hello World!');
} catch (err) {
} finally {
}
for (var i = 0; i < 10; i++) {
if (i === 1) {
continue;
}
if (i === 3) {
break;
}
console.log(i);
}
console.log(function () {
var x = 4;
console.log(1);
if (x) {
console.log(2);
for (var i = 0; i < 3; i++) {
console.log(3);
return x;
console.log(5);
}
console.log(6);
}
console.log(7);
}());
var x = 2;
switch (x) {
case 1:
console.log(1);
//falls through
case 2:
console.log(2);
case 3:
console.log(3);
break;
case 4:
console.log(4);
default:
console.log(5);
}
switch (x) {
case 1:
console.log(1);
default:
console.log(2);
}
switch (x) {
case 2:
console.log(3);
break;
default:
console.log(4);
}
switch (x) {
case 2:
console.log(5);
default:
console.log(6);
}
switch (x) {
default:
console.log(7);
case 2:
console.log(8);
}
switch (x) {
default:
console.log(9);
break;
case 2:
console.log(10);
}
var z;
for (z in {a: 1, b: 2}) {
console.log(z);
}
for (var key in {a: 1, b: 2}) {
console.log(key);
}
abcdefg();
function abcdefg() {
console.log('should be called');
}
var obj = {};
obj.a = 3;
console.log(obj.a);
delete obj.a;
console.log(obj.a);
/*jshint ignore:start*/
with ({a: 1, b: 2}) {
console.log(a, b);
}
/*jshint ignore:end*/