• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15const array1 = ['a', 'b', 'c'];
16const array2 = ['d', 'e', 'f'];
17const array3 = array1.concat(array2);
18print(array3);
19
20const letters = ["a", "b", "c"];
21const numbers = [1, 2, 3];
22
23const alphaNumeric = letters.concat(numbers);
24print(alphaNumeric);
25
26const num1 = [1, 2, 3];
27const num2 = [4, 5, 6];
28const num3 = [7, 8, 9];
29
30const numbers1 = num1.concat(num2, num3);
31
32print(numbers1);
33
34
35const letters1 = ["a", "b", "c"];
36
37const alphaNumeric1 = letters1.concat(1, [2, 3]);
38
39print(alphaNumeric1);
40
41const num11 = [[1]];
42const num22 = [2, [3]];
43
44const numbers2 = num1.concat(num22);
45
46print(numbers2);
47// [[1], 2, [3]]
48
49num11[0].push(4);
50
51print(numbers2);
52
53var target = {0:"a",1:"b",[Symbol.isConcatSpreadable]:"truish"};
54var obj=new Proxy(target,{
55    get(a,p){
56        print(p.toString());
57        return a[p];
58    }
59})
60[].concat(obj);
61print([1, , 3].concat([4, 5])); // [1, empty, 3, 4, 5]
62print([1, 2].concat([3, , 5])); // [1, 2, 3, empty, 5]
63
64const emptyArr = [];
65print(emptyArr.concat([]).length);
66