forked from chakra-core/ChakraCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForLoop.js
More file actions
72 lines (63 loc) · 1.81 KB
/
ForLoop.js
File metadata and controls
72 lines (63 loc) · 1.81 KB
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
//-------------------------------------------------------------------------------------------------------
// 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 = 6;
var giraffe = 8;
var zebra = x + giraffe;
function f(t) {
return t + t;
}
var cat = f(zebra);
rat = cat * 2;
while (rat > 4) {
rat = rat - 3;
cat = cat + 4;
}
for (var i = 4; i < zebra; ++i) {
cat = cat - 1;
}
var dragon = rat / 2;
dragon += 8;
WScript.Echo(x)
WScript.Echo(giraffe)
WScript.Echo(zebra)
WScript.Echo(cat)
WScript.Echo(rat)
WScript.Echo(dragon);
function MatchCollectionLocalCollection(collection, value)
{
for (var i = 0; i < collection.length; i++)
{
if (collection[i] == value)
return true;
}
return false;
}
WScript.Echo(MatchCollectionLocalCollection(["car", "truck"] , "car"));
WScript.Echo(MatchCollectionLocalCollection(["car", "truck"] , "foo"));
var gCollection = ["car", "truck"];
function MatchCollectionGlobalCollection(value)
{
for (var i = 0; i < gCollection.length; i++)
{
if (gCollection[i] == value)
return true;
}
return false;
}
WScript.Echo(MatchCollectionGlobalCollection("car"));
WScript.Echo(MatchCollectionGlobalCollection("foo"));
function MatchCollectionGlobalCollectionandValue()
{
for (var i = 0; i < gCollection.length; i++)
{
if (gCollection[i] == gValue)
return true;
}
return false;
}
var gValue = "car";
WScript.Echo(MatchCollectionGlobalCollectionandValue());
gValue = "foo";
WScript.Echo(MatchCollectionGlobalCollectionandValue());