• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021 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 */
15
16//test spread Array
17var arr1 = [...Array(16).keys()];
18print(arr1.length);
19print(arr1);
20
21var arr2 = [1, 2, 4, 6, 7, 8, 9, 54];
22var arr3 = [...arr2];
23print(arr3.length);
24print(arr3);
25
26//test spread Set
27const set1 = new Set();
28set1.add(42);
29set1.add(42);
30set1.add(13);
31set1.add(23);
32
33var arr4 = [...set1.keys()];
34print(arr4.length);
35print(arr4);
36
37var arr5 = [...set1];
38print(arr5.length);
39print(arr5);
40
41//test spread map
42const map1 = new Map();
43map1.set('a', 1);
44map1.set('b', 2);
45map1.set('c', 3);
46
47var arr6 = [...map1.keys()];
48print(arr6.length);
49print(arr6);
50
51var arr7 = [...map1.values()];
52print(arr7.length);
53print(arr7);
54