-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathDoWhile.js
47 lines (40 loc) · 1.14 KB
/
DoWhile.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
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
// Use do..while as a statement inside if..else
var str="if (1) do WScript.Echo(1); while (false); else 1;";
try
{
eval(str);
}
catch (e)
{
WScript.Echo(e);
}
// Use do..while as a statement inside another do..while
str="do do WScript.Echo(2); while (false); while(false);"
try
{
eval(str);
}
catch (e)
{
WScript.Echo(e);
}
// do..while without a semicolon at the end, followed by another statement
// do while surrounds a statement without a semicolon, but ended with a newline
var a = 10;
do
WScript.Echo(3)
while (false)
var b=20;
with(a) do WScript.Echo(4); while (false)
for(var i=0; i<5; i++)
do
WScript.Echo("5."+i);
while(false)
// do..while as the last statement ended by EOF
do
WScript.Echo(6)
while (false)