forked from sweet-js/sweet-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scratchpad.js
192 lines (183 loc) · 2.19 KB
/
scratchpad.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
188
189
190
191
192
/*
* This is a JavaScript Scratchpad.
*
* Enter some JavaScript, then Right Click or choose from the Execute Menu:
* 1. Run to evaluate the selected text,
* 2. Inspect to bring up an Object Inspector on the result, or,
* 3. Display to insert the result in a comment after the selection.
*/
var i = 0;
function f() {};
// Function Declarations
f(); function foo() {} /42/i
/*
/42/i
*/
{false} function foo() {} /42/i
/*
/42/i
*/
if (false) false
function foo() {} /42/i
/*
/42/i
*/
i = 0;function foo() {} /42/i
/*
/42/i
*/
if (false) {} function foo() {} /42/i
/*
/42/i
*/
function foo() {} function foo() {} /42/i
/*
/42/i
*/
if (false) function foo() {} /42/i
/*
/42/i
*/
{function foo() {} /42/i}
/*
/42/i
*/
foo
function foo() {} /42/i
/*
/42/i
*/
42
function foo() {} /42/i
/*
/42/i
*/
[2,3]
function foo() {} /42/i
/*
/42/i
*/
{a: 2}
function foo() {} /42/i
/*
/42/i
*/
"foo"
function foo() {} /42/i
/*
/42/i
*/
/42/i
function foo() {} /42/i
/*
/42/i
*/
for (;;) {
break
function foo() {} /42/i
}
/*
undefined
*/
debugger
function foo() {} /42/i
/*
/42/i
*/
switch ("foo") {
case "foo": {true;}
case function foo() {} /42/i: {true;}
}
/*
undefined
*/
if(false)
false
else
function foo() {} /42/i
/*
/42/i
*/
[42][0]
function foo() {} /42/i
/*
/42/i
*/
// Function Expressions
x = function foo() {} /42/i
/*
NaN
*/
x = 42 / function foo() {} /42/i
/*
NaN
*/
42 >> function foo() {} /42/i
/*
42
*/
i = 0;+function foo() {} /42/i
/*
NaN
*/
(function foo() {} /42/i)
/*
NaN
*/
foo /
function foo() {} /42/i
/*
NaN
*/
new function foo() {} /42/i
/*
NaN
*/
typeof function foo() {} /42/i
/*
NaN
*/
2 in function foo() {} /42/i
/*
Exception: invalid 'in' operand NaN
@Scratchpad:1
*/
(function foo() {
return function foo() {} /42/i
})()
/*
NaN
*/
do function foo() {} /42/ while (false);
/*
Exception: missing while after do-loop body
Scratchpad:1
*/
void function foo() {} /42/i
/*
NaN
*/
[function foo() {} /42/i]
/*
NaN
*/
4,
function foo() {} /42/i
/*
NaN
*/
++function foo() {} /42/i
/*
Exception: invalid increment operand
Scratchpad:1
*/
x /= function foo() {} /42/i
/*
NaN
*/
// parse errors
if (false) false function foo() {} /42/i
/*
Exception: missing ; before statement
Scratchpad:1
*/