-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathTApply1.js
48 lines (36 loc) · 1.51 KB
/
TApply1.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
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
function test(x) {
WScript.Echo("test apply simple call with one argument: " + x );
}
test.apply(null, ["val1", "val2", "val3"]);
function test1(x, y, z) {
WScript.Echo("test apply simple call with 3 arguments: " + x + " , " + y + " , " + z);
}
test1.apply(null, ["p1", "p2", "p3"]);
function test2(x, y) {
WScript.Echo("In test2 apply ");
this.a = x;
this.b = y
}
var o1 = new Object();
test2.apply(o1, [9, "secondValue"]);
WScript.Echo("test apply call to function that sets properties in 'this': " + o1.a + " , " + o1.b );
function test3() {
WScript.Echo("In test3 apply ");
this.a = "param1";
this.b = 99
}
test3.apply();
WScript.Echo("test apply call to function that sets properties in global 'this': " + a + " , " + b);
function testArg(x, y, z) {
WScript.Echo("**run tests with Arguments object");
test.apply(null, arguments);
test1.apply(null, arguments);
var o1 = new Object();
test2.apply(o1, arguments);
WScript.Echo("test apply call to function that sets properties in 'this': " + o1.a + " , " + o1.b);
}
testArg("1stArg", "2ndArg", "3rdArg");