1/* 2 * Copyright (c) 2024 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 */ 15import assert from 'assert'; 16function foo() { 17 return { Propx1: 1, Propy1: 2 }; 18} 19const { Propx1: Propx1, Propy1: Propy1 } = foo(); 20assert(Propx1 === 1, 'success'); 21assert(Propy1 === 2, 'success'); 22// let Propx2 =3; 23// let Propy3 =4; 24// let Propy4 =5; 25const { Propx2: Propx2, Obj: { Propy3: Propy3, Propy4: Propy4 } } = { Propx2: 12, Obj: { Propy3: 13, Propy4: 14 } }; 26assert(Propx2 === 12, 'success'); 27assert(Propy3 === 13, 'success'); 28assert(Propy4 === 14, 'success'); 29const { ...rest1 } = { prop1: 11, prop2: 12 }; 30assert(rest1.prop1 === 11, 'success'); 31assert(rest1.prop2 === 12, 'success'); 32const { prop3: prop3, ...rest2 } = { prop3: 13, prop4: 14 }; 33assert(prop3 === 13, 'success'); 34assert(rest2.prop4 === 14, 'success'); 35let name11 = 'hello'; 36let info = { name11: name11 }; 37