-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathSwitch2.js
65 lines (59 loc) · 1.79 KB
/
Switch2.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
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
var x = { i : 1, j : 2, k : 3 };
switch(x.i)
{
case "1":
WScript.Echo("error - found \"1\"");
break;
default:
WScript.Echo("error - found default");
break;
case 1.000000001:
WScript.Echo("error - found 1.000000001");
break;
case 1:
WScript.Echo("found 1");
break;
}
switch(x.q)
{
case undefined:
WScript.Echo("found undefined");
break;
default:
WScript.Echo("found a value");
}
x.f = function() { this.j++; return this.j; }
q();
function q() {
switch(x.j)
{
case 1:
WScript.Echo("error - found 1");
return;
case x.f():
WScript.Echo("error - found x.f()");
return;
case 2:
WScript.Echo("found 2, x.j = " + x.j);
return;
case 3:
WScript.Echo("error - found 3");
return;
}
}
var y = new Object();
y.z = x;
y.w = x;
switch(x)
{
case y.w:
WScript.Echo("found y.w");
break;
case y.z:
WScript.Echo("found y.z");
break;
}