forked from chakra-core/ChakraCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscopeFunction.js
More file actions
55 lines (42 loc) · 1.32 KB
/
scopeFunction.js
File metadata and controls
55 lines (42 loc) · 1.32 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
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
function outer(val)
{
var iic = val + 1;
function inner() { return iic++; }
return inner;
}
var fouter = outer(3);
var gouter = outer(5);
function ctr(val)
{
var iic = val;
this.inc = function () { return iic++; }
this.dec = function () { return iic--; }
}
var fctr = new ctr(3);
var fctr2 = fctr;
var gctr = new ctr(5);
WScript.SetTimeout(testFunction, 50);
/////////////////
function testFunction()
{
////
fouter();
////
telemetryLog(`fouter(): ${fouter()}`, true); //5
telemetryLog(`gouter(): ${gouter()}`, true); //6
////
fctr.inc();
////
telemetryLog(`fctr.inc(): ${fctr.inc()}`, true); //4
telemetryLog(`gctr.inc(): ${gctr.inc()}`, true); //5
////
fctr2.dec();
fctr2.dec();
////
telemetryLog(`post decrement -- fctr.inc(): ${fctr.inc()}`, true); //3
telemetryLog(`post decrement -- gctr.inc(): ${gctr.inc()}`, true); //6
}