Files
zhangyukun a97747fe18 Description:sync from code from wgr_master to ohos
Signed-off-by: zhangyukun <zhangyukun8@huawei.com>
Change-Id: Ic66a9e649de8c0ce530483296fe323b8f50621fb
2021-12-21 09:36:03 +08:00

54 lines
1.3 KiB
JavaScript

/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//test spread Array
var arr1 = [...Array(16).keys()];
print(arr1.length);
print(arr1);
var arr2 = [1, 2, 4, 6, 7, 8, 9, 54];
var arr3 = [...arr2];
print(arr3.length);
print(arr3);
//test spread Set
const set1 = new Set();
set1.add(42);
set1.add(42);
set1.add(13);
set1.add(23);
var arr4 = [...set1.keys()];
print(arr4.length);
print(arr4);
var arr5 = [...set1];
print(arr5.length);
print(arr5);
//test spread map
const map1 = new Map();
map1.set('a', 1);
map1.set('b', 2);
map1.set('c', 3);
var arr6 = [...map1.keys()];
print(arr6.length);
print(arr6);
var arr7 = [...map1.values()];
print(arr7.length);
print(arr7);