-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathArrayConcat.js
63 lines (50 loc) · 1.36 KB
/
ArrayConcat.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
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
function ExplicitToString(value)
{
var result;
if (value instanceof Array)
{
result = "[";
for (var idx = 0; idx < value.length; idx++)
{
if (idx > 0)
{
result += ", ";
}
var item = value[idx];
result += ExplicitToString(item);
}
result += "]";
}
else if (value == null)
{
result = "'null'";
}
else if (value == undefined)
{
result = "'undefined'";
}
else
{
result = value /* .toString() */;
}
return result;
}
function Print(name, value)
{
var result = name + " = " + ExplicitToString(value);
WScript.Echo(result);
}
var a = [1, 2, 3];
Print("a", a);
var b = a.concat(4, 5, 6);
Print("b", b);
var c = [1, [2, 3]];
Print("c", c);
var d = a.concat(4, [5, [6, [7]]]);
Print("d", d);
var e = a.concat([4, 5], [6, 7], [8, [9, [10]]]);
Print("e", e);