14514f5e3Sopenharmony_ci/*
24514f5e3Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
34514f5e3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
44514f5e3Sopenharmony_ci * you may not use this file except in compliance with the License.
54514f5e3Sopenharmony_ci * You may obtain a copy of the License at
64514f5e3Sopenharmony_ci *
74514f5e3Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
84514f5e3Sopenharmony_ci *
94514f5e3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
104514f5e3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
114514f5e3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
124514f5e3Sopenharmony_ci * See the License for the specific language governing permissions and
134514f5e3Sopenharmony_ci * limitations under the License.
144514f5e3Sopenharmony_ci */
154514f5e3Sopenharmony_ciconst array1 = ['a', 'b', 'c'];
164514f5e3Sopenharmony_ciconst array2 = ['d', 'e', 'f'];
174514f5e3Sopenharmony_ciconst array3 = array1.concat(array2);
184514f5e3Sopenharmony_ciprint(array3);
194514f5e3Sopenharmony_ci
204514f5e3Sopenharmony_ciconst letters = ["a", "b", "c"];
214514f5e3Sopenharmony_ciconst numbers = [1, 2, 3];
224514f5e3Sopenharmony_ci
234514f5e3Sopenharmony_ciconst alphaNumeric = letters.concat(numbers);
244514f5e3Sopenharmony_ciprint(alphaNumeric);
254514f5e3Sopenharmony_ci
264514f5e3Sopenharmony_ciconst num1 = [1, 2, 3];
274514f5e3Sopenharmony_ciconst num2 = [4, 5, 6];
284514f5e3Sopenharmony_ciconst num3 = [7, 8, 9];
294514f5e3Sopenharmony_ci
304514f5e3Sopenharmony_ciconst numbers1 = num1.concat(num2, num3);
314514f5e3Sopenharmony_ci
324514f5e3Sopenharmony_ciprint(numbers1);
334514f5e3Sopenharmony_ci
344514f5e3Sopenharmony_ci
354514f5e3Sopenharmony_ciconst letters1 = ["a", "b", "c"];
364514f5e3Sopenharmony_ci
374514f5e3Sopenharmony_ciconst alphaNumeric1 = letters1.concat(1, [2, 3]);
384514f5e3Sopenharmony_ci
394514f5e3Sopenharmony_ciprint(alphaNumeric1);
404514f5e3Sopenharmony_ci
414514f5e3Sopenharmony_ciconst num11 = [[1]];
424514f5e3Sopenharmony_ciconst num22 = [2, [3]];
434514f5e3Sopenharmony_ci
444514f5e3Sopenharmony_ciconst numbers2 = num1.concat(num22);
454514f5e3Sopenharmony_ci
464514f5e3Sopenharmony_ciprint(numbers2);
474514f5e3Sopenharmony_ci// [[1], 2, [3]]
484514f5e3Sopenharmony_ci
494514f5e3Sopenharmony_cinum11[0].push(4);
504514f5e3Sopenharmony_ci
514514f5e3Sopenharmony_ciprint(numbers2);
524514f5e3Sopenharmony_ci
534514f5e3Sopenharmony_civar target = {0:"a",1:"b",[Symbol.isConcatSpreadable]:"truish"};
544514f5e3Sopenharmony_civar obj=new Proxy(target,{
554514f5e3Sopenharmony_ci    get(a,p){
564514f5e3Sopenharmony_ci        print(p.toString());
574514f5e3Sopenharmony_ci        return a[p];
584514f5e3Sopenharmony_ci    }
594514f5e3Sopenharmony_ci})
604514f5e3Sopenharmony_ci[].concat(obj);
614514f5e3Sopenharmony_ciprint([1, , 3].concat([4, 5])); // [1, empty, 3, 4, 5]
624514f5e3Sopenharmony_ciprint([1, 2].concat([3, , 5])); // [1, 2, 3, empty, 5]
634514f5e3Sopenharmony_ci
644514f5e3Sopenharmony_ciconst emptyArr = [];
654514f5e3Sopenharmony_ciprint(emptyArr.concat([]).length);
664514f5e3Sopenharmony_ci
674514f5e3Sopenharmony_cilet px = new Proxy([], {});
684514f5e3Sopenharmony_ci
694514f5e3Sopenharmony_cilet idx = 0;
704514f5e3Sopenharmony_ciclass A extends Array {
714514f5e3Sopenharmony_ci    constructor() {
724514f5e3Sopenharmony_ci        super(2);
734514f5e3Sopenharmony_ci        idx++;
744514f5e3Sopenharmony_ci        if (idx == 1) {
754514f5e3Sopenharmony_ci            this.concat(A);
764514f5e3Sopenharmony_ci        }
774514f5e3Sopenharmony_ci        return px;
784514f5e3Sopenharmony_ci    }
794514f5e3Sopenharmony_ci}
804514f5e3Sopenharmony_cilet a = new A();
814514f5e3Sopenharmony_ciprint("proxy defineproperty success!");